html {
    box-sizing: border-box;
    overflow-x: hidden;
}

*,
*::before,
*::after {
    box-sizing: inherit;
}

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    background-color: #eee;
}

.config-error-banner {
    width: 100%;
    box-sizing: border-box;
    padding: 1rem 1.5rem;
    background-color: #c00;
    color: #fff;
    font-size: 0.95rem;
    list-style-position: inside;
}

.config-error-banner ul {
    margin: 0.5rem 0 0 0;
    padding-left: 1rem;
}

.config-error-banner code {
    background: rgba(255,255,255,0.25);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
}

.config-error-banner p {
    margin: 0.75rem 0 0 0;
    opacity: 0.95;
}

.setup-container {
    max-width: 560px;
    margin: 2rem auto;
    padding: 1.5rem;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.setup-container h1 {
    margin-top: 0;
}

.setup-form .form-group {
    margin-bottom: 1rem;
}

.setup-form label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.setup-form input[type="text"],
.setup-form select,
.setup-form textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 0.5rem;
    font: inherit;
}

.setup-form textarea {
    font-family: monospace;
    font-size: 0.9rem;
}

.form-hint {
    display: block;
    font-size: 0.85rem;
    color: #555;
    margin-top: 0.25rem;
}

.setup-form .form-actions {
    margin-top: 1.5rem;
}

.setup-form button[type="submit"] {
    padding: 0.5rem 1rem;
    font-size: 1rem;
    cursor: pointer;
}

.setup-docs {
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: #666;
}

.hidden {
    display: none;
}

.thumbnail img.hidden-image {
    visibility: hidden !important;
    background-color: white !important;
}


.loading {
    position: relative;
}

.loading img {
    visibility: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin-top: -20px;
    margin-left: -20px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top: 4px solid #000;
    border-radius: 50%;
    z-index: 2;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.fade-in {
    opacity: 0;
    transition: opacity 1s;
}

.fade-in.show {
    opacity: 1;
}


header {
    width: 100%;
    max-width: 100%;
    padding: 20px;
    background: linear-gradient(to right, #333, #555);
    color: #fff;
    text-align: center;
    flex-shrink: 0;
}

.header-top {
    position: relative;
    padding: 10px 20px;
}

.logo {
    text-align: center;
}

.logo h1 {
    margin: 0;
    font-size: 2em;
    color: #00c3ff;
}

.user-nav {
    position: absolute;
    top: 10px;
    right: 20px;
    display: flex;
    align-items: center;
}

.account-dropdown {
    position: relative;
    display: inline-block;
}

.account-dropdown-summary {
    padding: 0.4rem;
    min-width: 2.25rem;
    min-height: 2.25rem;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 0.9375rem;
    background-color: #00c3ff;
    color: #1a1a1a;
    border: none;
    cursor: pointer;
    font-family: inherit;
    list-style: none;
}

.account-dropdown-summary::-webkit-details-marker {
    display: none;
}

.account-dropdown-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    height: 1.35rem;
}

.account-dropdown-icon svg {
    width: 100%;
    height: 100%;
}

.account-dropdown-summary:hover {
    background-color: #00a1cc;
    color: #1a1a1a;
}

.account-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    min-width: 10rem;
    padding: 0.5rem 0;
    background: #444;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.25);
    z-index: 20;
}

.account-dropdown-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.account-dropdown-list li {
    display: block;
}

.account-dropdown-list a,
.account-dropdown-list button {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 0.5rem 1rem;
    text-align: left;
    border-radius: 0;
    border: none;
    background: transparent;
    color: #fff;
    font-size: 0.9375rem;
    text-decoration: none;
    cursor: pointer;
    font-family: inherit;
}

.account-dropdown-list a:hover,
.account-dropdown-list button:hover {
    background-color: rgba(0, 195, 255, 0.25);
    color: #fff;
}

.account-dropdown-list .user-nav-signed-in {
    display: block;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    color: rgba(255,255,255,0.9);
    border-bottom: 1px solid rgba(255,255,255,0.2);
}

.user-nav-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.user-nav-list a,
.user-nav-list button {
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-size: 0.9375rem;
    text-decoration: none;
    background-color: #00c3ff;
    color: #1a1a1a;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.user-nav-list a:hover,
.user-nav-list button:hover {
    background-color: #00a1cc;
    color: #1a1a1a;
}

.site-description {    
    margin: 10px;
    font-size: 1.2em;
}

#header {
    position: absolute;
    top: 0;
    right: 0;
    padding: 10px;
}



.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.gallery-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem 1.5rem;
    max-width: 90%;
    margin: 1rem auto;
    padding: 1rem 1.25rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.mobile-filters-trigger {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.65rem 1rem;
    font-size: 0.9375rem;
    font-family: inherit;
    font-weight: 600;
    color: #1a1a1a;
    background: #00c3ff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.mobile-filters-trigger:hover {
    background: #00a1cc;
}

.mobile-filters-trigger-icon {
    display: inline-block;
    width: 1.25rem;
    height: 1rem;
    background: linear-gradient(to bottom, currentColor 0.15em, transparent 0.15em, transparent 0.35em, currentColor 0.35em, currentColor 0.55em, transparent 0.55em, transparent 0.75em, currentColor 0.75em);
    background-size: 80% 100%;
    background-repeat: no-repeat;
    background-position: center;
}

.gallery-toolbar-desktop {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem 1.5rem;
    flex: 1;
    min-width: 0;
}

.filters-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1100;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    box-sizing: border-box;
}

.filters-lightbox.is-open {
    display: flex;
}

.filters-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.filters-lightbox-panel {
    position: relative;
    width: 100%;
    max-width: 22rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

.filters-lightbox-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e5e5e5;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
}

.filters-lightbox-title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #1a1a1a;
}

.filters-lightbox-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    font-size: 1.5rem;
    line-height: 1;
    color: #666;
    background: none;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.filters-lightbox-close:hover {
    color: #1a1a1a;
    background: #eee;
}

.filters-lightbox-content {
    padding: 1.25rem;
}

.filters-lightbox-content .gallery-toolbar-filters,
.filters-lightbox-content .gallery-controls {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 1rem;
    margin-left: 0;
    width: 100%;
}

.filters-lightbox-content .toolbar-field {
    width: 100%;
    min-width: 0;
    max-width: none;
}

.filters-lightbox-content .toolbar-field label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #374151;
    letter-spacing: 0.02em;
    margin-bottom: 0.15rem;
}

.filters-lightbox-content .toolbar-field input,
.filters-lightbox-content .toolbar-field select {
    width: 100%;
    box-sizing: border-box;
    padding: 0.5rem 0.75rem;
    font-size: 0.9375rem;
    font-family: inherit;
    color: #1a1a1a;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    min-height: 2.25rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.filters-lightbox-content .toolbar-field input::placeholder {
    color: #666;
}

.filters-lightbox-content .toolbar-field input:focus,
.filters-lightbox-content .toolbar-field select:focus {
    outline: none;
    border-color: #00c3ff;
    box-shadow: 0 0 0 2px rgba(0, 195, 255, 0.25);
}

.filters-lightbox-content .toolbar-field select {
    cursor: pointer;
    appearance: auto;
}

.gallery-toolbar-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem 1.5rem;
}

.gallery-toolbar .gallery-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem 1.5rem;
    margin-left: auto;
}

.gallery-toolbar .toolbar-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.gallery-toolbar .toolbar-field.filter-item {
    min-width: 10rem;
    max-width: 14rem;
}

.gallery-toolbar .toolbar-field-search {
    min-width: 12rem;
    max-width: 20rem;
    flex: 1;
}

.gallery-toolbar .toolbar-field label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: 0.02em;
}

.gallery-toolbar .toolbar-field input,
.gallery-toolbar .toolbar-field select {
    padding: 0.5rem 0.75rem;
    font-size: 0.9375rem;
    font-family: inherit;
    color: #1a1a1a;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    min-height: 2.25rem;
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.gallery-toolbar .toolbar-field input {
    width: 100%;
}

.gallery-toolbar .toolbar-field input::placeholder {
    color: #666;
}

.gallery-toolbar .toolbar-field input:focus,
.gallery-toolbar .toolbar-field select:focus {
    outline: none;
    border-color: #00c3ff;
    box-shadow: 0 0 0 2px rgba(0, 195, 255, 0.3);
}

.gallery-toolbar .toolbar-field select {
    cursor: pointer;
    appearance: auto;
}


.admin-buttons {
    margin-top: 10px;
}

.admin-buttons button {
    margin: 5px;
    padding: 10px 20px;
    border-radius: 5px;
    background-color: #007bff;
    color: #fff;
    border: none;
    cursor: pointer;
}

.admin-buttons button:hover {
    background-color: #0056b3;
}

.admin-only {
    display: none;
}

.user-nav-signed-in {
    font-size: 0.875rem;
    color: rgba(255,255,255,0.9);
    padding: 0.25rem 0.5rem;
}

.admin-panel-wrap {
    display: inline-block;
}

.admin-panel {
    display: inline-block;
    margin: 0;
    position: relative;
}

.admin-panel summary {
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-size: 0.9375rem;
    background-color: #00c3ff;
    color: #1a1a1a;
    border: none;
    cursor: pointer;
    list-style: none;
    font-family: inherit;
}

.admin-panel summary::-webkit-details-marker {
    display: none;
}

.admin-panel summary::after {
    content: ' \25BC';
    font-size: 0.7em;
    opacity: 0.8;
}

.admin-panel[open] summary::after {
    content: ' \25B2';
}

.admin-panel .admin-buttons {
    position: absolute;
    margin-top: 4px;
    padding: 10px 12px;
    background: #444;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    z-index: 10;
}

.admin-panel .admin-buttons button {
    margin: 0;
}

.account-dropdown-menu .admin-panel .admin-buttons {
    position: static;
    margin-top: 0.5rem;
    margin-left: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.account-dropdown-menu .admin-panel summary {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    color: #fff;
}

.account-dropdown-menu .admin-panel summary:hover {
    background-color: rgba(0, 195, 255, 0.25);
    color: #fff;
}

main {
    /* see theme specific stylesheet */
}

/* Override theme so gallery uses full width and grid fills symmetrically (no empty space on the right).
   body main#gallery beats theme's main; align-self: stretch overrides body's align-items: center. */
body main#gallery {
    width: 100%;
    max-width: 100%;
    margin-top: 20px;
    padding: 0 1rem;
    box-sizing: border-box;
    display: grid;
    /* Theme can override --gallery-grid-min-column (e.g. larger for wide 16:9, smaller for tall 2:3). */
    grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--gallery-grid-min-column, 260px)), 1fr));
    gap: 10px;
    align-self: stretch;
}

body main#gallery .image-container {
    display: block;
    min-width: 0;
    width: 100%;
}

body main#gallery .image-container img {
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 2 / 3;
    object-fit: cover;
}

.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s;
}

.lightbox.visible {
    opacity: 1;
}

.lightbox-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-height: 90vh;
    padding: 20px;
    background: rgba(0, 0, 0, 0.8);
}

.lightbox img {
    max-height: 70vh;
    width: 100%;
    object-fit: contain;
    display: block;
}

.text-container {
    text-align: left;
    color: #fff;
    max-width: 80vw;
    align-self: start;
    margin-top: 20px;
    max-height: 40vh;
    overflow-y: auto;
}

.text-container h2 {
    margin-top: 0px;
    font-size: 1.4em;
    margin-bottom: 10px;
}

.text-container h3 {
    margin: 5px 0;
    font-style: italic;
    font-size: 1em;
    margin-bottom: 10px;
}

.text-container p {
    margin: 5px 0;
    font-size: 1em;
    line-height: 1.4em;
}

@media (max-width: 768px) {
    .header-top {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .gallery-toolbar {
        flex-direction: row;
        align-items: stretch;
        width: 100%;
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
        padding: 1rem;
        min-width: 0;
    }
    .mobile-filters-trigger {
        display: inline-flex;
        min-height: 44px;
    }
    .gallery-toolbar-desktop {
        display: none;
    }
    .account-dropdown-menu {
        max-height: 70vh;
        overflow-y: auto;
        min-width: 12rem;
    }
    .account-dropdown-summary {
        min-height: 44px;
    }
    body main#gallery {
        padding: 0 0.75rem;
        gap: 0.75rem;
    }
    body main#gallery .image-container {
        margin: 0;
        width: 100%;
        min-width: 0;
    }
    .text-container {
        max-width: 100%;
    }
    .text-container p {
        font-size: 0.8em;
        line-height: 1.2em;
    }    
    .lightbox img {
        max-height: 60vh;
    }
}


.thumbnail {
    cursor: pointer;
    position: relative;
    width: 100%;
    background-color: #f0f0f0;
    overflow: hidden;    
}

.thumbnail img {
    display: block;    
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;    
    opacity: 0; /* Initially hide the image */
    transition: opacity 1s; /* Fade-in effect */
}

.thumbnail img[srcset] {
    opacity: 1; /* Show the image when srcset is set */
}

.thumbnail.loading img {
    visibility: visible; /* Show the placeholder image */
}

.thumbnail .button-container {
    position: absolute;
    bottom: -60px; /* Initially hide the buttons below the thumbnail */
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    width: 100%;
    transition: bottom 0.3s ease, opacity 0.3s ease, visibility 0.3s ease; /* Smooth slide effect */
    opacity: 0; /* Initially invisible */
    visibility: hidden; /* Initially not visible */
}

.thumbnail:hover .button-container {
    bottom: 10px; /* Slide the buttons into view */
    opacity: 1; /* Make the buttons visible */
    visibility: visible; /* Make the buttons visible */
}

.thumbnail button {
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    margin: 5px;
}


#login-form {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

#login-form input {
    display: block;
    width: 100%;
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid #ccc;
}

#login-form button {
    width: 100%;
    padding: 10px;
    background-color: #4CAF50;
    color: white;
    border: none;
    cursor: pointer;
}

#login-form button:hover {
    background: #45a049;
}

.error-message {
    color: #d9534f;
    margin-top: 10px;
}

.image-container {
    position: relative;
    display: inline-block;
    margin: 10px;
    cursor: pointer;
}

.image-container img {
    max-width: 100%;
    height: auto;
    display: block;
}

.admin-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    display: none;
    gap: 5px;
}

.image-container:hover .admin-controls {
    display: flex;
}

.admin-controls button {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: background-color 0.2s;
}

.admin-controls button:hover {
    background: rgba(0, 0, 0, 0.9);
}

.edit-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.edit-modal-content {
    background: white;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.edit-modal h2 {
    margin-top: 0;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.form-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.form-buttons button {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.form-buttons button[type="submit"],
.form-buttons .save-button {
    background: #4CAF50;
    color: white;
}

.form-buttons button[type="submit"]:hover,
.form-buttons .save-button:hover {
    background: #45a049;
}

.form-buttons .cancel-button {
    background: #f44336;
    color: white;
}

.form-buttons .cancel-button:hover {
    background: #da190b;
}
