* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    height: 100dvh;
    overflow: hidden;
    background: #1a1a1a;
    color: #eee;
}

.hidden { display: none !important; }
.error { color: #e74c3c; margin-top: 8px; font-size: 14px; }

/* Login */
#login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100dvh;
    background: #1a1a1a;
}

.login-box {
    text-align: center;
    padding: 40px;
    background: #2a2a2a;
    border-radius: 12px;
    min-width: 280px;
}

.login-box h1 {
    font-size: 28px;
    margin-bottom: 8px;
    color: #4CAF50;
}

.login-box p {
    color: #888;
    margin-bottom: 24px;
}

.login-box input {
    display: block;
    width: 100%;
    padding: 10px 14px;
    margin-bottom: 12px;
    border: 1px solid #444;
    border-radius: 6px;
    background: #333;
    color: #eee;
    font-size: 16px;
}

.login-box button {
    width: 100%;
    padding: 10px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
}

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

/* Toolbar */
#toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: #2a2a2a;
    border-bottom: 1px solid #444;
    height: 42px;
}

.app-title {
    font-weight: bold;
    color: #4CAF50;
    font-size: 16px;
}

#album-select {
    padding: 4px 8px;
    background: #333;
    color: #eee;
    border: 1px solid #444;
    border-radius: 6px;
    font-size: 13px;
    flex: 1;
    min-width: 0;
}

#status-text {
    color: #888;
    font-size: 12px;
    white-space: nowrap;
}

#action-controls {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
    padding: 6px 10px;
    background: rgba(30, 30, 30, 0.9);
    border-radius: 8px 8px 0 0;
    z-index: 1000;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.4);
}

#action-controls button {
    padding: 4px 10px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
}

#before-btn, #both-btn, #after-btn {
    background: #2980b9;
    color: white;
}

#cancel-btn {
    background: #555;
    color: #eee;
}

#remove-btn {
    background: #c0392b;
    color: white;
}

/* Main layout — desktop: side tray, mobile: bottom tray */
#app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
}

#main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

#map-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#map {
    width: 100%;
    height: 100%;
}

/* Tray — desktop */
#tray {
    width: 180px;
    background: #222;
    border-left: 1px solid #444;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#tray-header {
    padding: 8px;
    font-weight: bold;
    font-size: 12px;
    color: #aaa;
    border-bottom: 1px solid #333;
    text-align: center;
}

#tray-photos {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
}

/* Tray time groups */
.tray-group {
    margin-bottom: 8px;
}

.tray-group-label {
    font-size: 10px;
    color: #666;
    padding: 2px 2px 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tray-group-photos {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

/* Photo thumbnails in tray */
.tray-thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 3px;
    cursor: grab;
    border: 2px solid transparent;
    transition: border-color 0.15s;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.tray-thumb:hover {
    border-color: #4CAF50;
}

.tray-thumb.dragging {
    opacity: 0.4;
}

.tray-thumb.selected {
    border-color: #4CAF50;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.7);
}

/* Place mode — crosshair cursor on map */
#map.place-mode {
    cursor: crosshair;
}

/* Long-press preview overlay */
#preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

#preview-img {
    max-width: 80vw;
    max-height: 60vh;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.6);
    object-fit: contain;
}

/* Map photo markers */
.photo-marker {
    border-radius: 3px;
    border: 2px solid white;
    box-shadow: 0 1px 4px rgba(0,0,0,0.5);
    cursor: pointer;
    transition: border-color 0.15s, transform 0.15s;
}

.photo-marker:hover {
    transform: scale(1.15);
    z-index: 1000 !important;
}

.photo-marker.locatr-assigned {
    border-color: #4CAF50;
    cursor: grab;
}

.photo-marker.highlighted {
    border-color: #FFD700;
    border-width: 3px;
    transform: scale(1.3);
    z-index: 999 !important;
}

/* Video badges */
.marker-wrap {
    position: relative;
    display: inline-block;
}

.video-badge {
    position: absolute;
    bottom: 1px;
    right: 1px;
    font-size: 8px;
    color: white;
    background: rgba(0,0,0,0.6);
    border-radius: 2px;
    padding: 0 2px;
    line-height: 1.2;
    pointer-events: none;
}

.tray-thumb-wrap {
    position: relative;
    display: inline-block;
}

.video-badge-tray {
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 9px;
    color: white;
    background: rgba(0,0,0,0.6);
    border-radius: 2px;
    padding: 0 3px;
    line-height: 1.3;
    pointer-events: none;
}

/* Drop zone indicator on map */
#map.drag-over {
    outline: 3px dashed #4CAF50;
    outline-offset: -3px;
}

.tray-empty {
    padding: 16px;
    color: #666;
    text-align: center;
}

/* Mobile layout */
@media (max-width: 768px) {
    #main-content {
        flex-direction: column;
    }

    #map-container {
        flex: 1;
        min-height: 0;
    }

    #tray {
        width: 100%;
        height: 110px;
        flex: 0 0 110px;
        border-left: none;
        border-top: 2px solid #4CAF50;
    }

    #tray-header {
        padding: 4px 8px;
        font-size: 11px;
        font-weight: bold;
        color: #4CAF50;
        background: #1a1a1a;
    }

    #tray-photos {
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        padding: 4px 8px;
        -webkit-overflow-scrolling: touch;
        height: calc(110px - 26px);
    }

    .tray-group {
        display: inline-block;
        vertical-align: top;
        margin-bottom: 0;
        margin-right: 12px;
        white-space: normal;
        max-width: 200px;
    }

    .tray-group-label {
        font-size: 10px;
        white-space: nowrap;
        color: #aaa;
        margin-bottom: 4px;
    }

    .tray-group-photos {
        display: flex;
        flex-wrap: wrap;
        gap: 3px;
    }

    .tray-thumb {
        width: 44px;
        height: 44px;
    }

    .tray-empty {
        padding: 8px;
        font-size: 13px;
    }

    .app-title {
        font-size: 14px;
    }

    #status-text {
        font-size: 11px;
    }
}
