.app {
    height: 100dvh;
    overflow: hidden;
}
.app-header {
    height: 82px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 34px;
    background: #fff;
}
.header-middle {
    font-size: 11px;
    color: #8a9387;
    display: flex;
    align-items: center;
    gap: 9px;
    letter-spacing: 1px;
}
.header-actions {
    display: flex;
    align-items: center;
    gap: 22px;
}
.avatar {
    border: 1px solid #e2e7d9;
    border-radius: 3px;
    width: 36px;
    height: 36px;
    background: #edf1e5;
    color: #6a7d58;
    font-family: Georgia, serif;
    font-size: 16px;
}
.app-body {
    height: calc(100dvh - 82px);
    display: grid;
    grid-template-columns: 264px 1fr;
}
.sidebar {
    display: flex;
    flex-direction: column;
    padding: 34px 22px 24px;
    background: #fcfcf9;
    border-right: 1px solid var(--line);
    min-height: 0;
}
.sidebar-heading {
    padding: 0 11px;
}
.sidebar-heading h1 {
    font-size: 24px;
    letter-spacing: 1px;
    margin: 12px 0 9px;
}
.sidebar-heading .muted {
    font-size: 11px;
}
.search-box {
    display: flex;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 3px;
    padding-left: 12px;
    gap: 6px;
    background: white;
    margin: 26px 0 20px;
}
.search-box span {
    font-size: 24px;
    font-weight: 400;
    color: #98a090;
}
.search-box input {
    border: 0;
    background: transparent;
    padding: 11px 5px;
    font-size: 11px;
    min-width: 0;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    font-size: 12px;
    padding: 13px 11px;
    border-radius: 3px;
    margin: 4px 0;
}
.nav-item > span:first-child {
    color: #859677;
    font-size: 16px;
}
.nav-item.active {
    background: #eaf0e4;
    color: #365b35;
    font-weight: 600;
}
.count {
    margin-left: auto;
    font-size: 10px;
    color: #8a9880;
}
.group-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 33px 10px 9px;
    font-size: 11px;
    color: #8c9686;
}
.group-heading button {
    font-size: 21px;
    color: #708368;
}
.group-list {
    overflow-y: auto;
    min-height: 30px;
}
.group-row {
    display: flex;
    align-items: center;
}
.group-row .nav-item {
    min-width: 0;
    flex: 1;
}
.group-row .nav-item .group-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: inherit;
    font-size: 12px;
}
.group-row .edit-group {
    font-size: 18px;
    width: 26px;
    flex-shrink: 0;
    color: #829279;
}
.sidebar-bottom {
    margin-top: auto;
    padding: 20px 4px 0;
}
.sidebar-ad {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-top: 16px;
}
.sidebar-ad-label { font-size: 10px; color: var(--muted); }
.sidebar-ad a { display: block; max-width: 100%; }
.sidebar-ad-banner { display: block; max-width: 100%; height: auto; border: 0; }
.sidebar-ad-tracking { position: absolute; bottom: 0; right: 0; border: 0; }
.storage-note {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 15px 0;
}
.storage-symbol {
    font-size: 28px;
    color: #899b79;
}
.storage-note strong {
    font-size: 10px;
    font-weight: 500;
}
.storage-note p {
    font-size: 9px;
    margin-top: 6px;
    color: #98a08f;
}
.sidebar-bottom > .button {
    font-size: 10px;
    background: #f3f5ef;
    color: #687c58;
    min-height: 38px;
}
.private-note {
    font-size: 8px;
    margin: 18px -2px 0;
    color: #a0a896;
    white-space: nowrap;
}
.workspace {
    position: relative;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 28px;
    background: #f6f7f1;
}
.workspace-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin: 0 0 24px;
    gap: 16px;
}
.view-tools {
    display: flex;
    align-items: center;
    gap: 12px;
}
/* Compact segmented controls share a 3px corner radius. */
body .workspace-toolbar .icon-toggle {
    position: relative;
    display: flex;
    flex: 0 0 auto;
    gap: 0;
    width: max-content;
    min-width: 0;
    height: 44px;
    padding: 0;
    border-radius: 3px;
    background: #fffffff2;
    box-shadow: 0 2px 10px #172a1814;
    isolation: isolate;
}
body .workspace-toolbar .icon-toggle::before {
    content: "";
    position: absolute;
    left: 6px;
    top: 6px;
    width: 32px;
    height: 32px;
    border-radius: 3px;
    background: #435f35;
    box-shadow: 0 1px 4px #243b3326;
    transition: transform 180ms ease;
    pointer-events: none;
}
body .workspace-toolbar .icon-toggle:has(> button:nth-child(2)[aria-pressed="true"])::before { transform: translateX(44px); }
body .workspace-toolbar .icon-toggle:has(> button:nth-child(3)[aria-pressed="true"])::before { transform: translateX(88px); }
body .workspace-toolbar .icon-toggle button {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 44px;
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    border: 0;
    border-radius: 3px;
    background: transparent;
    box-shadow: none;
    color: #43563c;
    cursor: pointer;
    transition: color 180ms ease;
}

body .workspace-toolbar .icon-toggle button[aria-pressed="true"] { color: #fff; }
body .workspace-toolbar .icon-toggle button:focus-visible {
    outline: 2px solid #739960;
    outline-offset: 1px;
}
.icon-toggle svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}
@media (prefers-reduced-motion: reduce) {
    body .workspace-toolbar .icon-toggle::before,
    body .workspace-toolbar .icon-toggle button { transition: none; }
}
.map-panel {
    position: relative;
    flex: 1;
    min-height: 200px;
    border: 1px solid #dce4d4;
    border-radius: 3px;
    overflow: hidden;
    isolation: isolate;
}
.map-panel #map {
    position: absolute;
    inset: 0;
    background: #e6ebdd;
    z-index: 0;
}
body .workspace:has(> #map-panel:not([hidden])) {
    padding: 0;
}
.workspace:has(> #map-panel:not([hidden])) > .map-panel {
    position: absolute;
    inset: 0;
    min-height: 0;
    border: 0;
    border-radius: 3px;
}
.map-empty {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 350px;
    max-width: calc(100% - 70px);
    text-align: center;
    border: 1px solid #eef0e6;
    background: #ffffffed;
    padding: 32px 25px;
    border-radius: 3px;
    box-shadow: 0 10px 40px #465c3610;
    z-index: 500;
}
.empty-icon {
    display: block;
    font-size: 34px;
    color: #8b9e78;
    margin-bottom: 16px;
}
.map-empty h3 {
    font-size: 16px;
    margin-bottom: 13px;
}
.map-empty p {
    font-size: 11px;
    line-height: 1.9;
    color: #8a9381;
    margin-bottom: 21px;
}
.map-bottom-label {
    position: absolute;
    left: 18px;
    bottom: 76px;
    display: flex;
    align-items: center;
    gap: 7px;
    z-index: 500;
    font-size: 9px;
    background: #fffffff0;
    padding: 9px 12px;
    border-radius: 3px;
    color: #77866b;
    max-width: calc(100% - 80px);
}
.map-fit {
    position: absolute;
    bottom: 76px;
    right: 13px;
    z-index: 500;
    background: white;
    border: 1px solid #dfe5d6;
    border-radius: 3px;
    font-size: 22px;
    width: 36px;
    height: 36px;
    box-shadow: 0 2px 10px #34462214;
}
.grid-panel {
    overflow-y: auto;
    flex: 1;
    padding: 2px;
}
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}
.media-card {
    border: 1px solid var(--line);
    border-radius: 3px;
    background: #fff;
    overflow: hidden;
    text-align: left;
    padding: 0;
    min-width: 0;
    transition:
        transform 0.18s,
        box-shadow 0.18s;
}
.media-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px #30442d12;
}
.card-image {
    aspect-ratio: 4/3;
    background: #e9eee2;
    position: relative;
    display: grid;
    place-items: center;
    overflow: hidden;
    color: #93a286;
    font-size: 32px;
}
.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    inset: 0;
}
.media-badge {
    position: absolute;
    bottom: 9px;
    left: 10px;
    font-size: 9px;
    color: white;
    background: #273b34b8;
    border-radius: 3px;
    padding: 4px 6px;
}
.location-missing-label {
    display: inline-block;
    margin-top: 6px;
    padding: 3px 7px;
    border-radius: 3px;
    background: #f4ebd9;
    color: #705324;
    font-size: 11px;
    font-weight: 600;
}
.card-content {
    padding: 14px;
}
.card-content h3 {
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.card-content p {
    font-size: 10px;
    color: #94a087;
    margin-top: 8px;
}
.empty-state {
    text-align: center;
    padding: 80px 15px;
}
.empty-state h3 {
    font-size: 17px;
    margin-bottom: 14px;
}
.empty-state p {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 22px;
}
.loading-bar {
    position: absolute;
    top: 100px;
    right: 38px;
    z-index: 700;
    background: #fff;
    padding: 10px 18px;
    border-radius: 3px;
    box-shadow: 0 3px 20px #2b422310;
    font-size: 11px;
}
.photo-map-marker {
    border: 3px solid white;
    border-radius: 3px;
    box-shadow: 0 3px 12px #23422845;
    background: #e9eddf;
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    place-items: center;
    font-size: 25px;
    color: #627d4e;
    transition: width 160ms ease, height 160ms ease,
        margin 160ms ease, box-shadow 160ms ease;
}
@media (hover: hover) and (pointer: fine) {
    .photo-map-marker:hover {
        width: 80px !important;
        height: 80px !important;
        margin-left: -40px !important;
        margin-top: -72px !important;
        z-index: 10000 !important;
        box-shadow: 0 5px 18px #23422865;
    }
}
@media (prefers-reduced-motion: reduce) {
    .photo-map-marker {
        transition: none;
    }
}
.leaflet-container .photo-map-marker img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.photo-map-cluster > div {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
}
.leaflet-container {
    font-family: inherit;
}
.leaflet-control-attribution {
    font-size: 9px !important;
    line-height: 1.4;
    max-width: min(620px, calc(100% - 12px));
}
.leaflet-bottom.leaflet-right {
    width: 100%;
}
.leaflet-popup-content-wrapper {
    border-radius: 3px;
}
.map-panel .leaflet-bar,
.map-panel .leaflet-bar a:first-child,
.map-panel .leaflet-bar a:last-child,
.map-panel .leaflet-control-layers {
    border-radius: 3px;
}
.map-popup {
    background: none;
    border: 0;
    font: inherit;
    font-size: 12px;
    color: #365b35;
    padding: 3px;
}

.storage-import-status {
    position: absolute;
    z-index: 450;
    top: 86px;
    left: 16px;
    max-width: min(460px, calc(100% - 80px));
    max-height: 150px;
    overflow-y: auto;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 2px 8px #18221c12;
    pointer-events: auto;
    font-size: 11px;
    line-height: 1.65;
}
.storage-import-status p {
    margin: 0;
}
.storage-import-status .import-note {
    color: var(--muted);
    font-size: 10px;
    margin-top: 5px;
}
.storage-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
}
.storage-import-detail,
.storage-import-help {
    font-size: 11px;
    line-height: 1.7;
}
@media (max-width: 760px) {
    .storage-import-status {
        top: 140px;
        left: 10px;
        max-width: calc(100% - 76px);
        max-height: 118px;
        padding: 6px 8px;
        font-size: 10px;
    }
    .storage-row {
        align-items: flex-start;
        flex-wrap: wrap;
    }
    .storage-actions {
        justify-content: flex-start;
    }
}

.workspace:has(> #grid-panel:not([hidden])) > .storage-import-status {
    position: relative;
    top: auto;
    left: auto;
    max-width: 100%;
    margin-bottom: 12px;
}


.storage-import-progress {
    display: block;
    height: 5px;
    width: 100%;
    margin: 6px 0 8px;
    overflow: hidden;
    border-radius: 3px;
    background: #dce8dd;
}
.storage-import-progress-fill {
    display: block;
    height: 100%;
    width: 35%;
    border-radius: 3px;
    background: #426c45;
    animation: storage-import-sweep 0.8s ease-in-out infinite;
}
.storage-import-progress.is-complete .storage-import-progress-fill {
    width: 100%;
    animation: none;
}
@keyframes storage-import-sweep {
    from { transform: translateX(-100%); }
    to { transform: translateX(286%); }
}
@media (prefers-reduced-motion: reduce) {
    .storage-import-progress-fill {
        animation: none;
    }
}

.storage-import-progress-text {
    display: block;
    margin-top: 4px;
    font-weight: 600;
}
.storage-import-meter {
    display: block;
    appearance: none;
    width: 100%;
    height: 100%;
    border: 0;
    background: transparent;
    color: #426c45;
}
.storage-import-meter::-webkit-progress-bar {
    background: transparent;
}
.storage-import-meter::-webkit-progress-value {
    background: #426c45;
    border-radius: 3px;
}
.storage-import-meter::-moz-progress-bar {
    background: #426c45;
    border-radius: 3px;
}

.album-selection { padding: 18px; margin-bottom: 20px; border: 1px solid var(--line); border-radius: 3px; background: #fff; }
.album-selection-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.album-selection-heading h2 { margin: 0; font-size: 17px; }
#album-picker-form { display: grid; gap: 8px; margin-top: 14px; }
#album-picker-form .field-hint, #album-picker-count { margin: 0; }
#album-picker-name-field { min-width: 0; }
#album-picker-error { color: #a32e2e; margin: 0; }
.media-card.album-selectable { position: relative; }
.media-card.album-selectable[aria-checked="true"] { outline: 3px solid #286c60; outline-offset: -3px; }
.album-selection-check { position: absolute; z-index: 2; top: 10px; left: 10px; display: grid; place-items: center; width: 28px; height: 28px; color: #286c60; background: white; border: 2px solid #286c60; border-radius: 3px; }
.media-card[aria-checked="true"] .album-selection-check { color: white; background: #286c60; }

#album-picker-form input, #album-picker-form select { width: 100%; min-width: 0; }

/* Image placeholders share a visible loading state across map, grid and detail. */
.preview-loading {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    height: 100%;
    min-height: 100px;
    background: #e9eee2;
    color: #4b6547;
}
.preview-loading::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(110deg, transparent 20%, #ffffffb8 50%, transparent 80%);
    transform: translateX(-100%);
    animation: preview-loading-shimmer 1.8s ease-in-out infinite;
}
.preview-loading-ring {
    width: 28px;
    height: 28px;
    border: 3px solid #55764c30;
    border-top-color: #55764c;
    border-radius: 50%;
    animation: preview-loading-spin 0.8s linear infinite;
}
.preview-loading-label,
.preview-unavailable {
    font-size: 12px;
    line-height: 1.5;
    text-align: center;
}
.preview-loading-compact {
    min-height: 0;
    gap: 0;
}
.preview-loading-compact .preview-loading-ring {
    width: 18px;
    height: 18px;
    border-width: 2px;
}
.photo-map-marker [data-thumbnail-id]:not(img) {
    width: 100%;
    height: 100%;
}
@keyframes preview-loading-spin {
    to { transform: rotate(360deg); }
}
@keyframes preview-loading-shimmer {
    to { transform: translateX(100%); }
}
@media (prefers-reduced-motion: reduce) {
    .preview-loading-ring,
    .preview-loading::before { animation: none; }
}
