:root {
    --pgm-ink: #172126;
    --pgm-muted: #61706d;
    --pgm-paper: #f8faf8;
    --pgm-panel: rgba(255, 255, 255, 0.86);
    --pgm-line: rgba(23, 33, 38, 0.16);
    --pgm-accent: #0f7b75;
    --pgm-accent-dark: #07514d;
    --pgm-red: #e05b3f;
    --pgm-glass: rgba(255, 255, 255, 0.8);
    --pgm-menu-bg: rgba(68, 68, 68, 0.8);
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    min-height: 100%;
    margin: 0;
}

.pgm-body {
    color: var(--pgm-ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.pgm-shell {
    display: flex;
    align-items: stretch;
    justify-content: center;
    width: 100vw;
    height: 100vh;
    height: 100svh;
    height: 100dvh;
    min-height: 100vh;
    padding: 0;
    background: var(--pgm-paper);
    overflow: hidden;
}

.pgm-map-card {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    height: 100svh;
    height: 100dvh;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    overflow: hidden;
}

.pgm-map-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px;
    border-bottom: 0;
    background: var(--pgm-menu-bg);
    backdrop-filter: none;
}

.pgm-map-primary-actions,
.pgm-map-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.pgm-mobile-menu {
    display: none;
    position: relative;
    z-index: 40;
}

.pgm-map-header h1 {
    margin: 0;
    border-radius: 7px;
    background: var(--pgm-menu-bg);
    color: #fff;
    font-size: clamp(24px, 4vw, 42px);
    line-height: 1;
    letter-spacing: 0;
    padding: 6px 10px;
}

.pgm-upload-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: 42px;
    border: 0;
    border-radius: 7px;
    background: var(--pgm-red);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-size: 14px;
    font-weight: 800;
    padding: 10px 14px;
    text-decoration: none;
}

.pgm-upload-button:hover {
    background: #c94c33;
}

.pgm-upload-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border: 2px solid currentColor;
    border-radius: 50%;
    line-height: 1;
}

.pgm-map-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    border: 0;
    border-radius: 7px;
    background: var(--pgm-menu-bg);
    color: #fff;
    font-size: 14px;
    font-weight: 750;
    padding: 8px 12px;
    text-decoration: none;
}

button.pgm-map-link {
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
}

.pgm-menu-icon {
    position: relative;
    display: inline-block;
    width: 17px;
    height: 17px;
    flex: 0 0 17px;
}

.pgm-menu-icon::before,
.pgm-menu-icon::after {
    content: "";
    position: absolute;
    box-sizing: border-box;
}

.pgm-icon-view::before {
    inset: 3px 1px;
    border: 2px solid currentColor;
    border-radius: 999px;
}

.pgm-icon-view::after {
    top: 6px;
    left: 6px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
}

.pgm-icon-dashboard::before {
    inset: 2px;
    border: 2px solid currentColor;
    border-radius: 3px;
}

.pgm-icon-dashboard::after {
    top: 7px;
    left: 2px;
    width: 13px;
    height: 2px;
    background: currentColor;
    box-shadow: 0 -5px 0 -0.2px transparent, 5px -5px 0 -0.2px transparent;
}

.pgm-icon-login::before,
.pgm-icon-logout::before {
    top: 4px;
    right: 1px;
    width: 8px;
    height: 8px;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
    transform: rotate(45deg);
}

.pgm-icon-login::after,
.pgm-icon-logout::after {
    top: 8px;
    left: 2px;
    width: 13px;
    height: 2px;
    background: currentColor;
}

.pgm-icon-logout {
    transform: rotate(180deg);
}

.pgm-icon-register::before {
    top: 2px;
    left: 4px;
    width: 9px;
    height: 9px;
    border: 2px solid currentColor;
    border-radius: 50%;
}

.pgm-icon-register::after {
    left: 1px;
    bottom: 1px;
    width: 15px;
    height: 8px;
    border: 2px solid currentColor;
    border-bottom: 0;
    border-radius: 9px 9px 0 0;
}

.pgm-icon-upload::before {
    top: 2px;
    left: 7px;
    width: 3px;
    height: 13px;
    background: currentColor;
}

.pgm-icon-upload::after {
    top: 2px;
    left: 3px;
    width: 11px;
    height: 11px;
    border-top: 3px solid currentColor;
    border-left: 3px solid currentColor;
    transform: rotate(45deg);
}

.pgm-map-link:hover {
    border-color: rgba(224, 91, 63, 0.45);
    color: var(--pgm-red);
}

.pgm-username {
    max-width: min(34vw, 220px);
    overflow: hidden;
    color: #fff;
    font-size: 14px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pgm-mobile-menu summary {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 7px;
    background: var(--pgm-menu-bg);
    cursor: pointer;
    list-style: none;
}

.pgm-mobile-menu summary::-webkit-details-marker {
    display: none;
}

.pgm-mobile-menu summary span {
    position: absolute;
    width: 20px;
    height: 2px;
    border-radius: 999px;
    background: #fff;
    transition: transform 0.18s ease, opacity 0.18s ease;
}

.pgm-mobile-menu summary span:nth-child(1) {
    transform: translateY(-7px);
}

.pgm-mobile-menu summary span:nth-child(3) {
    transform: translateY(7px);
}

.pgm-mobile-menu[open] summary span:nth-child(1) {
    transform: rotate(45deg);
}

.pgm-mobile-menu[open] summary span:nth-child(2) {
    opacity: 0;
}

.pgm-mobile-menu[open] summary span:nth-child(3) {
    transform: rotate(-45deg);
}

.pgm-mobile-menu-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 18px;
    z-index: 1000;
    display: grid;
    gap: 8px;
    width: min(260px, calc(100vw - 36px));
    border: 0;
    border-radius: 8px;
        background: var(--pgm-menu-bg);
    backdrop-filter: none;
    box-shadow: none;
    padding: 10px;
}

.pgm-mobile-menu[open] .pgm-mobile-menu-panel {
    display: grid;
}

.pgm-mobile-menu-panel .pgm-map-link {
    justify-content: flex-start;
    background: var(--pgm-menu-bg);
    color: #fff;
}

.pgm-mobile-menu-panel .pgm-map-link,
.pgm-mobile-menu-panel .pgm-username {
    width: 100%;
}

.pgm-google-login {
    display: flex;
    align-items: center;
}

.pgm-mobile-menu-panel .pgm-google-login {
    width: 100%;
}

.pgm-map {
    position: relative;
    z-index: 1;
    flex: 1;
    height: 100%;
    min-height: 100vh;
    min-height: 100svh;
    min-height: 100dvh;
    border-top: 0;
    background: #e9f0ee;
}

.pgm-photo-slider {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 10px;
    z-index: 25;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding: 10px 18px 14px;
    background: rgba(255, 255, 255, 0.64);
    scroll-snap-type: none;
    scrollbar-width: thin;
}

.pgm-photo-slider::after {
    content: "";
    position: sticky;
    right: -18px;
    flex: 0 0 42px;
    margin-left: -42px;
    pointer-events: none;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.72));
}

.pgm-photo-slider.is-empty {
    display: none;
}

.pgm-slider-item {
    flex: 0 0 100px;
    width: 100px;
    height: 100px;
    border: 4px solid rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 8px 18px rgba(24, 32, 31, 0.2);
    cursor: pointer;
    overflow: hidden;
    padding: 0;
    scroll-snap-align: start;
}

.pgm-slider-item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pgm-status {
    display: none;
    margin: 0 18px 14px;
    max-width: min(520px, calc(100vw - 36px));
    padding: 9px 12px;
    border-radius: 8px;
    background: #fff1df;
    color: var(--pgm-muted);
    font-size: 14px;
}

.pgm-status.is-visible {
    display: block;
}

.pgm-dashboard-body {
    background: var(--pgm-paper);
}

.pgm-dashboard-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 42px;
}

.pgm-dashboard-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.pgm-dashboard-header h1 {
    margin: 0 0 8px;
    font-size: clamp(30px, 5vw, 54px);
    line-height: 1;
    letter-spacing: 0;
}

.pgm-dashboard-header p {
    margin: 0;
    color: var(--pgm-muted);
}

.pgm-dashboard-header nav {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.pgm-dashboard-notice {
    margin-bottom: 16px;
    border: 1px solid rgba(15, 123, 117, 0.24);
    border-radius: 8px;
    background: rgba(15, 123, 117, 0.1);
    color: var(--pgm-accent-dark);
    font-weight: 750;
    padding: 12px 14px;
}

.pgm-dashboard-notice.is-error {
    border-color: rgba(224, 91, 63, 0.28);
    background: #fff1df;
    color: #835329;
}

.pgm-dashboard-grid {
    display: grid;
    grid-template-columns: minmax(320px, 0.9fr) minmax(360px, 1.1fr);
    gap: 18px;
}

.pgm-dashboard-form,
.pgm-photo-list {
    border: 1px solid var(--pgm-line);
    border-radius: 8px;
    background: var(--pgm-panel);
    box-shadow: 0 18px 60px rgba(24, 32, 31, 0.08);
    padding: 18px;
}

.pgm-dashboard-form h2,
.pgm-photo-list h2 {
    margin: 0 0 16px;
    font-size: 22px;
    letter-spacing: 0;
}

.pgm-dashboard-form {
    display: grid;
    align-content: start;
    gap: 14px;
}

.pgm-dashboard-form label {
    display: grid;
    gap: 7px;
    color: var(--pgm-muted);
    font-size: 13px;
    font-weight: 800;
}

.pgm-submit-status,
.pgm-exif-status {
    margin: -4px 0 0;
    border-radius: 7px;
    background: rgba(15, 123, 117, 0.08);
    color: var(--pgm-muted);
    font-size: 13px;
    line-height: 1.45;
    padding: 10px 12px;
}

.pgm-submit-status[data-status="busy"] {
    background: rgba(224, 91, 63, 0.12);
    color: #9a3926;
    font-weight: 750;
}

.pgm-submit-status[data-status="error"] {
    background: #fff1df;
    color: #835329;
    font-weight: 750;
}

.pgm-exif-status[data-status="success"] {
    background: rgba(15, 123, 117, 0.12);
    color: var(--pgm-accent-dark);
}

.pgm-exif-status[data-status="warning"] {
    background: #fff1df;
    color: #835329;
}

.pgm-dashboard-form input,
.pgm-dashboard-form textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--pgm-line);
    border-radius: 7px;
    background: #fff;
    color: var(--pgm-ink);
    font: inherit;
    padding: 10px 12px;
}

.pgm-dashboard-form textarea {
    resize: vertical;
}

.pgm-upload-button:disabled,
.pgm-upload-button.is-busy {
    cursor: progress;
    opacity: 0.78;
}

.pgm-upload-button.is-busy .pgm-upload-icon {
    animation: pgm-spin 0.9s linear infinite;
}

@keyframes pgm-spin {
    to {
        transform: rotate(360deg);
    }
}

.pgm-form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.pgm-photo-list {
    display: grid;
    align-content: start;
    gap: 12px;
}

.pgm-photo-row {
    display: grid;
    grid-template-columns: 92px 1fr;
    gap: 12px;
    min-height: 92px;
    border: 1px solid var(--pgm-line);
    border-radius: 8px;
    background: #fff;
    padding: 10px;
}

.pgm-photo-row img {
    width: 92px;
    height: 92px;
    border-radius: 6px;
    object-fit: cover;
}

.pgm-photo-row h3 {
    margin: 0 0 6px;
    font-size: 16px;
}

.pgm-photo-row p {
    margin: 0 0 10px;
    color: var(--pgm-muted);
    font-size: 13px;
}

.pgm-photo-row a {
    margin-right: 10px;
    color: var(--pgm-accent-dark);
    font-weight: 750;
}

.pgm-login-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 9;
    width: min(420px, calc(100vw - 32px));
    padding: 26px;
    border-radius: 8px;
    transform: translate(-50%, -50%);
}

.pgm-login-panel h1 {
    margin: 0 0 10px;
    color: var(--pgm-ink);
    font-size: clamp(32px, 8vw, 48px);
    line-height: 1;
    letter-spacing: 0;
}

.pgm-login-panel p {
    margin: 0 0 22px;
    color: var(--pgm-muted);
    font-size: 15px;
    line-height: 1.55;
}

.pgm-kicker {
    margin-bottom: 10px !important;
    color: var(--pgm-accent) !important;
    font-size: 12px !important;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.login-username,
.login-password,
.login-remember,
.login-submit {
    margin: 0 0 14px;
}

.login-username label,
.login-password label {
    display: block;
    margin-bottom: 7px;
    color: var(--pgm-ink);
    font-size: 13px;
    font-weight: 750;
}

.login-username input,
.login-password input {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--pgm-line);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.82);
    color: var(--pgm-ink);
    font: inherit;
    padding: 10px 12px;
}

.login-remember label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--pgm-muted);
    font-size: 14px;
}

.login-submit .button {
    width: 100%;
    min-height: 46px;
    padding: 11px 14px;
}

.pgm-demo-logins {
    display: grid;
    gap: 7px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--pgm-line);
    color: var(--pgm-muted);
    font-size: 13px;
}

.pgm-demo-logins code {
    width: 100%;
    overflow-wrap: anywhere;
    border-radius: 6px;
    background: rgba(15, 123, 117, 0.1);
    color: var(--pgm-accent-dark);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    padding: 7px 9px;
}

.maplibregl-map {
    font-family: inherit;
}

.maplibregl-ctrl-attrib {
    font-size: 0.68rem;
}

.maplibregl-popup-content {
    width: min(300px, calc(100vw - 44px));
    max-width: calc(100vw - 44px);
    max-height: min(430px, calc(100vh - 120px));
    border-radius: 8px;
    padding: 10px;
    overflow: auto;
}

.photo-map-marker {
    display: block;
    width: 58px;
    height: 58px;
    border: 4px solid #fff;
    border-radius: 50%;
    background: #fff center / cover no-repeat;
    box-shadow: 0 0 0 7px rgba(224, 91, 63, 0.22), 0 10px 24px rgba(30, 40, 38, 0.34);
}

.cluster-marker {
    width: 48px;
    height: 48px;
    border: 4px solid #fff;
    border-radius: 50%;
    background: #243331;
    color: #fff;
    box-shadow: 0 0 0 8px rgba(36, 51, 49, 0.18), 0 10px 24px rgba(30, 40, 38, 0.34);
    cursor: pointer;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 850;
}

.cluster-popup {
    display: grid;
    width: min(220px, 68vw);
    max-height: 250px;
    overflow: auto;
    gap: 8px;
}

.cluster-popup button {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    min-width: 0;
    border: 1px solid var(--pgm-line);
    border-radius: 8px;
    background: #fff;
    color: var(--pgm-ink);
    cursor: pointer;
    padding: 6px;
    text-align: left;
}

.cluster-popup img {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
}

.cluster-popup span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.photo-popup {
    width: 100%;
    min-width: 0;
}

.photo-popup img {
    display: block;
    width: 100%;
    max-width: 100%;
    aspect-ratio: 4 / 3;
    max-height: min(250px, 45vh);
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 10px;
}

.photo-popup strong {
    display: block;
    margin-bottom: 4px;
    color: var(--pgm-ink);
    font-size: 15px;
}

.photo-popup p {
    margin: 0;
    color: var(--pgm-muted);
    font-size: 13px;
    line-height: 1.4;
}

@media (max-width: 640px) {
    .pgm-shell {
        padding: 0;
    }

    .pgm-map-card {
        position: relative;
        height: 100vh;
        height: 100svh;
        height: 100dvh;
        min-height: 100vh;
        border: 0;
        border-radius: 0;
    }

    .pgm-map-header {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        flex-direction: row;
        align-items: center;
        justify-content: flex-end;
        border-bottom: 0;
    background: var(--pgm-menu-bg);
        backdrop-filter: none;
    }

    .pgm-dashboard-header {
        align-items: stretch;
        flex-direction: column;
    }

    .pgm-map-primary-actions {
        min-width: 0;
    }

    .pgm-map-header h1 {
        display: block;
        font-size: 15px;
        padding: 6px 8px;
    }

    .pgm-desktop-action {
        display: none;
    }

    .pgm-mobile-menu {
        display: block;
    }

    .pgm-mobile-menu-panel {
        position: fixed;
        top: 74px;
        right: 12px;
        left: auto;
        z-index: 1000;
        width: min(280px, calc(100vw - 24px));
    }

    .pgm-map-link,
    .pgm-upload-button {
        width: 100%;
    }

    .pgm-map {
        height: 100%;
        min-height: 100vh;
        min-height: 100svh;
        min-height: 100dvh;
        border-top: 0;
    }

    .pgm-dashboard-grid,
    .pgm-form-row,
    .pgm-photo-row {
        grid-template-columns: 1fr;
    }

    .pgm-photo-row img {
        width: 100%;
        height: auto;
        aspect-ratio: 16 / 9;
    }
}
