/* The map owns the viewport; controls occupy independent floating panels. */
body .app {
    position: relative;
    --map-edge: 16px;
    --library-width: 264px;
}
body .app-body {
    display: block;
    height: 100dvh;
}
body .app-header {
    position: absolute;
    inset: var(--map-edge) var(--map-edge) auto;
    z-index: 650;
    height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    pointer-events: none;
}
.app-header > * {
    pointer-events: auto;
}
body .header-actions {
    gap: 10px;
    margin-top: 12px;
    padding: 4px;
    background: #ffffffed;
    border: 1px solid var(--line);
    border-radius: 3px;
    box-shadow: 0 3px 16px #243b3312;
}
body .header-actions .button {
    flex: 1;
    min-height: 36px;
    padding: 8px 12px;
}
body .floating-menu:hover { transform: none; }
body .floating-menu { display: flex; align-items: center; line-height: 1; }
.floating-menu-icon {
    display: block;
    flex: 0 0 16px;
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}
body .floating-menu {
    height: 44px;
    background: #ffffffed;
    border: 1px solid var(--line);
    border-radius: 3px;
    box-shadow: 0 3px 16px #243b3312;
}
body .sidebar {
    position: absolute;
    top: 76px;
    left: var(--map-edge);
    z-index: 640;
    display: flex;
    flex-direction: column;
    gap: 0;
    width: var(--library-width);
    max-width: calc(100% - 2 * var(--map-edge));
    max-height: calc(100dvh - 108px);
    padding: 24px 16px 18px;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #fcfcf9;
    border: 1px solid var(--line);
    border-radius: 3px;
    box-shadow: 0 5px 24px #243b3320;
}
body .sidebar > * {
    flex-shrink: 0;
}
.library-close {
    position: absolute;
    right: 10px;
    top: 10px;
    width: 32px;
    height: 32px;
    font-size: 23px;
}
body .sidebar-heading,
body .sidebar-bottom {
    display: block;
}
body .sidebar .group-heading {
    display: flex;
    margin-top: 20px;
}
body .sidebar .search-box {
    margin: 20px 0 12px;
    padding-left: 12px;
}
body .sidebar .search-box span {
    display: inline;
}
body .sidebar .library-nav,
body .sidebar .group-list {
    display: block;
    max-height: none;
    overflow: visible;
}
body .sidebar .nav-item {
    width: 100%;
    padding: 12px 10px;
    font-size: 12px;
}
body .sidebar .group-row .group-name {
    max-width: none;
}
body .sidebar .mobile-album-create {
    display: none;
}
body .workspace,
body .workspace:has(> #map-panel:not([hidden])) {
    position: absolute;
    inset: 0;
    padding: 0;
}
body .workspace > .workspace-toolbar {
    position: absolute;
    top: 76px;
    right: var(--map-edge);
    z-index: 600;
    margin: 0;
    padding: 0;
    gap: 8px;
    background: transparent;
    border: 0;
    border-radius: 3px;
    box-shadow: none;
}
body .workspace .leaflet-top {
    top: 144px;
}
body .workspace .leaflet-right .leaflet-control {
    margin-right: var(--map-edge);
}
.map-footer {
    position: absolute;
    left: max(var(--map-edge), env(safe-area-inset-left));
    right: max(var(--map-edge), env(safe-area-inset-right));
    bottom: max(var(--map-edge), env(safe-area-inset-bottom));
    z-index: 600;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    pointer-events: none;
}
.map-footer-controls {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
}
.map-navigation {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    flex-shrink: 0;
    pointer-events: auto;
}
body .map-footer .leaflet-control-zoom {
    float: none;
    margin: 0;
}
body .map-footer .leaflet-control-zoom a {
    width: 42px;
    height: 42px;
    line-height: 42px;
}
body .map-footer .map-fit {
    position: static;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    pointer-events: auto;
}
body .map-footer .map-bottom-label {
    position: static;
    min-width: 0;
    max-width: none;
    min-height: 36px;
    padding: 10px 12px;
    font-size: 11px;
    line-height: 1.5;
    box-shadow: 0 2px 10px #34462214;
}
.map-bottom-label .tiny-dot {
    flex-shrink: 0;
}
.map-attribution {
    max-width: min(620px, 100%);
    pointer-events: auto;
}
body .map-footer .leaflet-control-attribution {
    float: none;
    margin: 0;
    max-width: none;
    padding: 4px 8px;
    border-radius: 3px;
    background: #ffffffb8;
    color: #596653;
    text-align: right;
    overflow-wrap: anywhere;
}
body .map-footer .leaflet-control-attribution a {
    color: inherit;
}
.map-credit-details {
    display: inline-block;
    margin-left: 6px;
    text-align: left;
}
.map-credit-details summary {
    cursor: pointer;
    list-style: none;
    text-decoration: underline dotted;
    text-underline-offset: 2px;
}
.map-credit-details summary::-webkit-details-marker { display: none; }
.map-credit-details summary:focus-visible { outline: 2px solid currentColor; }
.map-credit-content {
    position: absolute;
    right: 0;
    bottom: calc(100% + 6px);
    width: min(340px, calc(100vw - 32px));
    padding: 10px 12px;
    border-radius: 4px;
    background: #fff;
    box-shadow: 0 2px 12px #172a1824;
    color: #43563c;
    font-size: 11px;
    line-height: 1.6;
}
.workspace:has(> #grid-panel:not([hidden])) .map-footer-controls,
.workspace:has(> #grid-panel:not([hidden])) .map-attribution {
    display: none;
}
body .workspace > .grid-panel {
    margin: 144px var(--map-edge) var(--map-edge);
    min-height: 0;
}
body .workspace .loading-bar {
    position: static;
    max-width: 100%;
    pointer-events: none;
}

body .storage-import-status {
    top: 154px;
    left: var(--map-edge);
}
body .workspace:has(> #grid-panel:not([hidden])) > .storage-import-status {
    position: relative;
    top: auto;
    left: auto;
    flex-shrink: 0;
    max-height: 100px;
    margin: 144px var(--map-edge) 0;
}
body .workspace:has(> .storage-import-status:not([hidden])) > .grid-panel {
    margin-top: 12px;
}
@media (min-width: 761px) {
    body .workspace > .workspace-toolbar {
        top: var(--map-edge);
    }
    body .workspace .leaflet-top {
        top: 84px;
    }
    body .workspace > .grid-panel {
        margin-top: 84px;
    }
    body .storage-import-status {
        top: 84px;
    }
    body .workspace:has(> #grid-panel:not([hidden])) > .storage-import-status {
        margin-top: 84px;
    }
    body .workspace:has(> .storage-import-status:not([hidden])) > .grid-panel {
        margin-top: 12px;
    }
}
@media (min-width: 1001px) {
    body .floating-menu,
    body .library-close {
        display: none;
    }
    body .app-header {
        justify-content: flex-end;
    }
    body .sidebar {
        top: var(--map-edge);
        max-height: calc(100dvh - 84px);
    }
    .map-footer-controls {
        justify-content: flex-end;
    }
    body .map-footer .map-bottom-label {
        position: absolute;
        left: 0;
        bottom: 0;
        max-width: calc(100% - 640px);
    }
    .app:has(.sidebar:not([hidden])) .map-empty {
        left: calc(50% + 140px);
    }
    body .app:has(.sidebar:not([hidden])) .grid-panel,
    body .app:has(.sidebar:not([hidden])) .workspace > #storage-import-status {
        margin-left: calc(var(--library-width) + 2 * var(--map-edge));
    }
    body .app:has(.sidebar:not([hidden])) .workspace:has(> #map-panel:not([hidden])) > .storage-import-status {
        margin-left: 0;
        left: calc(var(--library-width) + 2 * var(--map-edge));
    }
}
@media (max-width: 760px) {
    body .app {
        --map-edge: 10px;
    }
    body .floating-menu {
        width: 44px;
        justify-content: center;
        font-size: 20px;
        line-height: 1;
        padding: 10px;
        gap: 0;
    }
    .floating-menu-label {
        display: none;
    }
    body .header-actions {
        gap: 6px;
    }
    body .header-actions .button {
        font-size: 10px;
        padding: 8px;
    }
    body .workspace > .workspace-toolbar {
        top: 68px;
        flex-direction: column;
        align-items: flex-end;
        gap: 8px;
    }
    body .sidebar {
        top: 68px;
        max-height: calc(100dvh - 132px);
    }
    body .workspace .leaflet-top {
        top: 244px;
    }
    body .workspace > .grid-panel {
        margin-top: 134px;
    }
    body .storage-import-status {
        top: 184px;
    }
    body .workspace:has(> #grid-panel:not([hidden])) > .storage-import-status {
        margin-top: 134px;
    }
    body .map-empty {
        top: 56%;
        max-width: calc(100% - 100px);
        max-height: calc(100% - 270px);
        padding: 18px 14px;
        overflow-y: auto;
    }
}

/* Keep all import counters readable in a compact summary below the toolbar. */
body .storage-import-status {
    max-width: min(560px, calc(100% - 80px));
    padding: 7px 10px;
    line-height: 1.45;
    font-size: 11px;
}
body .storage-import-status .storage-import-progress-text {
    margin-top: 3px;
    font-weight: 500;
}
body .storage-import-status .storage-import-progress {
    height: 3px;
    margin: 5px 0 0;
}
body .storage-import-status .storage-import-progress-text + .storage-import-progress + p {
    margin-top: 6px;
}
@media (min-width: 1001px) {
    body .app:has(.sidebar:not([hidden])) .workspace:has(> #map-panel:not([hidden])) > .storage-import-status {
        max-width: min(560px, calc(100% - var(--library-width) - 3 * var(--map-edge)));
    }
}

/* Import details belong to the library footer, below its privacy notice. */
body .sidebar #storage-import-status {
    position: static;
    width: 100%;
    max-width: 100%;
    max-height: none;
    margin: 10px 0 0;
    padding: 8px;
    overflow: visible;
    overflow-wrap: anywhere;
    box-shadow: none;
}
body .sidebar .private-note {
    display: block;
}

.storage-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 3px;
    background: #e8f4ef;
    color: #23664c;
    font-size: 13px;
    line-height: 1.6;
}
.storage-loading-spinner {
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    border: 3px solid #b9d9ca;
    border-top-color: #23664c;
    border-radius: 50%;
    animation: storage-loading-spin 0.85s linear infinite;
}
@keyframes storage-loading-spin {
    to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
    .storage-loading-spinner { animation: none; }
}

/* Shared finish for floating actions and the circular view switches. */
body .floating-menu,
body .workspace-toolbar #album-pick-media,
body .map-footer .map-fit {
    min-height: 44px;
    border: 1px solid #43563c18;
    border-radius: 24px;
    background: #fffffff2;
    color: #43563c;
    box-shadow: 0 2px 10px #172a1814;
}
body .floating-menu,
body .map-footer .map-fit { border-radius: 3px; }
body .workspace-toolbar #album-pick-media:hover { transform: none; }
body .workspace-toolbar .view-tools { gap: 8px; }
body .map-footer .leaflet-control-zoom {
    overflow: hidden;
    border: 1px solid #43563c18;
    border-radius: 3px;
    box-shadow: 0 2px 10px #172a1814;
}
body .map-footer .leaflet-control-zoom a {
    background: #fffffff2;
    color: #43563c;
    font-size: 20px;
}

.map-footer-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    min-width: 0;
    flex: 1;
}
body .map-footer-info .map-bottom-label {
    position: static;
    width: 100%;
    max-width: none;
    flex: none;
}
body .map-footer-info .leaflet-control-attribution { text-align: left; }
.map-footer-info .map-credit-content { left: 0; right: auto; }
@media (min-width: 1001px) {
    .map-footer-info {
        position: absolute;
        left: 0;
        bottom: 0;
        max-width: calc(100% - 640px);
    }
}

/* Import details belong in storage settings, outside the library menu. */
body #settings-dialog #storage-import-status {
    position: static;
    width: 100%;
    max-width: none;
    max-height: none;
    margin: 16px 0 0;
    overflow: visible;
    font-size: 12px;
    line-height: 1.6;
    overflow-wrap: anywhere;
}
