:root {
    --bg: #f4f7f3;
    --panel: #ffffff;
    --panel-alt: #eef4ef;
    --text: #18251e;
    --muted: #68756d;
    --accent: #287a50;
    --accent-dark: #1d623e;
    --accent-soft: #e7f2e9;
    --border: #dfe7e0;
    --shadow: rgba(26, 53, 36, 0.06);
    color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    padding: 0;
    font-family: "DM Sans", sans-serif;
    background: var(--bg);
    color: var(--text);
}

body {
    background-image: linear-gradient(180deg, #f8faf7 0, var(--bg) 420px);
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }
img { max-width: 100%; display: block; }

.wrap {
    width: min(1440px, 100%);
    margin: 0 auto;
    padding: 28px 28px 56px;
}

.topbar {
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--border);
}

.topbar .wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 16px;
    padding-bottom: 16px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text);
    font-family: "Manrope", sans-serif;
    font-size: 1.15rem;
    font-weight: 800;
}

.brand::after {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    content: "";
}

nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

nav.site-nav a,
nav.site-nav summary {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid transparent;
    border-radius: 5px;
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 600;
}

nav.site-nav a:hover,
nav.site-nav summary:hover {
    border-color: var(--border);
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.nav-dropdown {
    position: relative;
}

.nav-dropdown summary {
    list-style: none;
    cursor: pointer;
}

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

.nav-dropdown summary::after {
    width: 6px;
    height: 6px;
    margin-left: 2px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    content: "";
    transform: translateY(-2px) rotate(45deg);
}

.nav-dropdown[open] summary::after {
    transform: translateY(1px) rotate(225deg);
}

.category-submenu {
    position: absolute;
    z-index: 30;
    top: calc(100% + 4px);
    left: 0;
    display: grid;
    min-width: 200px;
    gap: 3px;
    padding: 7px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(26, 53, 36, 0.12);
}

nav.site-nav .category-submenu a {
    width: 100%;
}

.submenu-empty {
    padding: 8px 12px;
    color: var(--muted);
    font-size: 0.9rem;
}

.nav-icon { width: 18px; height: 18px; flex: 0 0 auto; }

.menu-toggle {
    display: none;
    width: 42px;
    height: 40px;
    align-content: center;
    justify-items: center;
    gap: 5px;
    margin: 0;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: #fff;
    cursor: pointer;
}

.menu-toggle span {
    display: block;
    width: 19px;
    height: 2px;
    border-radius: 2px;
    background: var(--text);
}

main.wrap { padding-top: 34px; }

.panel {
    margin-bottom: 20px;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--panel);
    box-shadow: 0 3px 12px var(--shadow);
}

.stack { display: grid; gap: 2px; }
.stack > .panel { margin-bottom: 18px; }

.grid {
    display: grid;
    gap: 18px;
}

.grid > .panel { margin-bottom: 0; }

.two-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

h1, h2, h3 {
    margin-top: 0;
    color: var(--text);
    font-family: "Manrope", sans-serif;
    line-height: 1.2;
}

h1 { margin-bottom: 12px; font-size: 2rem; font-weight: 800; }
h2 { margin-bottom: 16px; font-size: 1.35rem; font-weight: 750; }
h3 { margin-bottom: 12px; font-size: 1.08rem; font-weight: 700; }
p { color: var(--muted); line-height: 1.65; }

input, textarea, select, button {
    width: 100%;
    margin-top: 7px;
    padding: 11px 13px;
    border: 1px solid #d6e0d8;
    border-radius: 5px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

input, textarea, select {
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--accent);
    outline: 0;
    box-shadow: 0 0 0 3px rgba(40, 122, 80, 0.12);
}

textarea { min-height: 110px; resize: vertical; }

label {
    display: block;
    margin-bottom: 14px;
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 600;
}

button {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

button:hover { border-color: var(--accent-dark); background: var(--accent-dark); }
button:disabled { cursor: wait; opacity: 0.65; }

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0 8px 0 0;
    vertical-align: middle;
}

button.button-danger {
    border-color: #b64b4b;
    background: #b64b4b;
    color: #fff;
}

button.button-danger:hover { border-color: #963b3b; background: #963b3b; }

.delete-album-form { margin: 16px 0 22px; }

.category-admin-list { display: grid; gap: 12px; }

.category-admin-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 180px;
    align-items: end;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
}

.category-edit-form {
    display: grid;
    grid-template-columns: minmax(140px, 1fr) 130px auto;
    align-items: end;
    gap: 10px;
}

.category-edit-form label { margin: 0; }
.category-edit-form button, .category-delete-form button { margin-top: 7px; }
.category-delete-form { min-width: 0; }

.album-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
    gap: 14px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.album-list li {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
}

.album-list li.album-card {
    display: grid;
    gap: 0;
    overflow: hidden;
    padding: 0;
}

.album-title {
    display: block;
    padding: 12px 15px 8px;
    color: var(--text);
    font-family: "Manrope", sans-serif;
    font-size: 1.02rem;
    font-weight: 700;
}

.album-preview {
    display: flex;
    width: 100%;
    height: 200px;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 0;
    background: var(--panel-alt);
}

.album-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.album-preview:hover img { transform: scale(1.025); }
.album-preview-locked { color: var(--accent); font-size: 1.8rem; }
.album-preview-empty { border: 1px dashed #cbd9ce; }

.album-card p {
    margin: 0;
    padding: 7px 15px 12px;
    font-size: 0.92rem;
}

.badge {
    display: inline-block;
    margin-left: 8px;
    padding: 4px 9px;
    border-radius: 4px;
    background: var(--accent-soft);
    color: var(--accent-dark);
    font-size: 0.72rem;
    font-weight: 700;
}

.badge.muted { background: #f0f3f0; color: var(--muted); }

.admin-photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.admin-photo-card {
    overflow: hidden;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
}

.admin-photo-card img {
    width: 100%;
    aspect-ratio: 4 / 3;
    margin-bottom: 10px;
    border-radius: 3px;
    object-fit: cover;
}

.admin-photo-form {
    display: grid;
    gap: 8px;
}

.geo-name-tool {
    margin-top: 10px;
}

.geo-name-tool > button,
.geo-name-result button {
    margin-top: 0;
}

.geo-name-result {
    margin-top: 8px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--panel-alt);
}

.geo-name-result p {
    margin: 0 0 8px;
    color: var(--text);
    overflow-wrap: anywhere;
}

.album-photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0;
}

.album-photo-card {
    position: relative;
    overflow: hidden;
    aspect-ratio: 4 / 3;
    background: var(--panel-alt);
}

.album-photo-card-link {
    position: absolute;
    inset: 0;
    display: block;
}

.album-photo-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.album-photo-card-title {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 10px 12px;
    background: rgba(54, 59, 56, 0.72);
    color: #fff;
    font-weight: 600;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.album-photo-card-link:focus-visible {
    z-index: 1;
    outline: 3px solid var(--accent);
    outline-offset: -3px;
}

.detail-image {
    width: 100%;
    max-height: 76vh;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--panel-alt);
    object-fit: contain;
}

.detail-title {
    margin: 8px 0 20px;
    text-align: center;
}

.detail-figure {
    margin: 0;
}

.photo-banderole {
    margin-top: 14px;
    padding: 14px 18px;
    border-left: 3px solid var(--accent);
    background: var(--accent-soft);
}

.capture-date {
    display: block;
    margin-bottom: 4px;
    color: var(--accent);
    font-size: 1.05rem;
    font-weight: 600;
}

.photo-caption-text {
    margin-bottom: 0;
}

.map-frame {
    width: 100%;
    height: 340px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--panel-alt);
}

.detail-list {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.detail-list li {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: #fbfcfb;
    color: var(--muted);
}

.detail-list strong { color: var(--text); }

.photo-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 16px;
}

.nav-link {
    display: inline-block;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: #fff;
    color: var(--accent-dark);
    font-size: 0.92rem;
    font-weight: 600;
}

.nav-link:hover { border-color: #a9c7b1; background: var(--accent-soft); }
.nav-link.disabled { opacity: 0.45; pointer-events: none; }

.dropzone { display: grid; gap: 12px; }

.dropzone-area {
    position: relative;
    display: grid;
    min-height: 170px;
    place-items: center;
    padding: 20px;
    border: 1px dashed #8db69a;
    border-radius: 6px;
    background: #f2f8f3;
    color: var(--accent-dark);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone-area.is-dragover { border-color: var(--accent); background: var(--accent-soft); }

.dropzone-area input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-progress-wrap { display: grid; gap: 7px; margin-top: 12px; }

.upload-progress {
    width: 100%;
    height: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #edf2ee;
}

.upload-progress-fill {
    display: block;
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
    transition: width 0.2s ease;
}

.upload-progress-text { color: var(--muted); font-size: 0.82rem; }

.upload-overlay {
    position: fixed;
    z-index: 999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(24, 37, 30, 0.28);
    inset: 0;
}

.upload-overlay.visible { display: flex; }

.upload-overlay-card {
    width: min(420px, 90vw);
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: #fff;
    box-shadow: 0 10px 32px rgba(26, 53, 36, 0.14);
}

.upload-overlay-card h3 { margin-bottom: 10px; }

.upload-overlay-bar {
    width: 100%;
    height: 9px;
    overflow: hidden;
    margin: 15px 0 11px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #edf2ee;
}

.upload-overlay-bar span {
    display: block;
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
    transition: width 0.2s ease;
}

.upload-overlay-status { color: var(--muted); font-size: 0.9rem; }

@media (max-width: 760px) {
    .wrap { padding: 22px 16px 40px; }
    .topbar .wrap { flex-direction: row; gap: 16px; }
    .panel { padding: 18px; }
    .two-columns { grid-template-columns: 1fr; }
    .category-admin-row { grid-template-columns: 1fr; }
    .category-edit-form { grid-template-columns: 1fr 110px; }
    .category-edit-form button { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
    .topbar .wrap { position: relative; }
    .menu-toggle { display: grid; }
    nav.site-nav {
        position: absolute;
        z-index: 20;
        top: calc(100% + 1px);
        right: 16px;
        display: none;
        width: min(240px, calc(100vw - 32px));
        align-items: stretch;
        flex-direction: column;
        gap: 3px;
        padding: 7px;
        border: 1px solid var(--border);
        border-radius: 6px;
        background: #fff;
        box-shadow: 0 8px 24px rgba(26, 53, 36, 0.12);
    }
    nav.site-nav.is-open { display: flex; }
    nav.site-nav a,
    nav.site-nav summary { width: 100%; }
    .category-submenu {
        position: static;
        min-width: 0;
        margin: 2px 0 4px 18px;
        padding: 4px;
        border: 0;
        border-left: 1px solid var(--border);
        border-radius: 0;
        box-shadow: none;
    }
}

@media (max-width: 440px) {
    .topbar .wrap { align-items: center; flex-direction: row; gap: 16px; }
    h1 { font-size: 1.7rem; }
    .admin-photo-grid, .album-photo-grid { grid-template-columns: 1fr; }
}
