:root {
    --primary: #e63946;
    --primary-hover: #d62828;
    --bg-color: #f8fafc;
    --sidebar-bg: rgba(255, 255, 255, 0.75);
    --text-color: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --danger: #f43f5e;
    --surface: #ffffff;
}

/* 전역 다크모드 변수 테마 */
body.dark-mode {
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);
    --surface: #1e293b;
    --sidebar-bg: rgba(15, 23, 42, 0.8);
    --primary: #ff6b6b;
    --primary-hover: #fa5252;
}

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

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    color: var(--text-color);
    background-color: var(--bg-color);
    overflow: hidden;
    -webkit-overflow-scrolling: auto;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    position: fixed; /* 페이지 전체화면 고정 (iOS 고질적 바운스 및 주소창 변동 레이아웃 붕괴 완벽 차단) */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overscroll-behavior: none;
}

/* 전체 앱 레이아웃 (플렉스 사용) */
#app {
    display: flex;
    height: 100%;
    width: 100%;
}

/* 사이드바 글래스모피즘(Glassmorphism) 효과 */
.sidebar {
    width: 380px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border-right: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    box-shadow: 4px 0 30px rgba(0, 0, 0, 0.06);
    position: relative;
}

/* 상단 헤더 부분 */
.sidebar-header {
    padding: 24px 20px;
    /* 요즘 유행하는 트렌디하고 무게감 있는 다크 그라데이션 */
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: none;
    /* 툴바와의 부드러운 연결을 위해 선 제거 */
}

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    text-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.logout-btn {
    color: white;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.25);
    padding: 8px 12px;
    border-radius: 8px;
    transition: background 0.2s;
    backdrop-filter: blur(4px);
    border: none;
    /* 버튼 태그의 기본 브라우저 테두리 제거 */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    /* 클릭 시 테두리 제거 */
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* 검색 폼 영역 */
.search-container {
    padding: 24px 20px 20px;
    background-color: white;
    border-bottom: 1px solid var(--border-color);
}

#search-form {
    display: flex;
    position: relative; /* 버튼 배치를 위해 상대 위치 지정 */
    align-items: center;
}

#location-input {
    flex: 1;
    padding: 14px 100px 14px 16px; /* 버튼 공간 확보 (우측 100px) */
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    font-family: inherit;
    background: #f8fafc;
    width: 100%;
}

#location-input:focus {
    border-color: var(--primary);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(230, 57, 70, 0.1);
}

#add-btn {
    position: absolute; /* 절대 위치 */
    right: 6px; /* 우측 끝에서 살짝 띄움 */
    top: 6px;
    bottom: 6px;
    padding: 0 16px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 8px; /* 내부 버튼에 맞춰 둥글게 */
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(230, 57, 70, 0.2);
    z-index: 2;
}

#add-btn:active {
    transform: scale(0.96);
}

#add-btn:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(230, 57, 70, 0.3);
}

.error-msg {
    color: var(--danger);
    font-size: 13px;
    margin-top: 10px;
    display: none;
    padding: 10px;
    border-radius: 8px;
    background: #fef2f2;
    border: 1px solid #fee2e2;
}

.list-header {
    padding: 24px 20px 12px;
}

.list-header h3 {
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

.list-header small {
    color: var(--text-muted);
    font-size: 13px;
    display: block;
    margin-top: 6px;
}

.stats {
    margin-top: 16px;
    padding: 14px 16px;
    background: #f1f5f9;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    display: flex;
    justify-content: space-between;
    border: 1px solid #e2e8f0;
}

/* 드래그 가능한 목록 스타일 */
.location-list {
    list-style: none;
    overflow-y: auto;
    flex: 1 1 0%;
    min-height: 0;
    padding: 0 20px 20px;
    overscroll-behavior: contain;
    /* 리스트 스크롤 시 부모 바운스 터치 전파 방지 */
    -webkit-overflow-scrolling: touch;
}

.location-item {
    background: #ffffff;
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: 14px;
    margin-top: 12px;
    display: flex;
    align-items: center;
    cursor: grab;
    transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
    animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.location-item:active {
    cursor: grabbing;
}

.location-item:hover {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.06);
    border-color: #cbd5e1;
}

.sortable-ghost {
    opacity: 0.4;
    background-color: #f8fafc;
}

.location-item .drag-handle {
    color: #cbd5e1;
    margin-right: 14px;
    font-size: 20px;
    cursor: grab;
}

.location-info {
    flex: 1;
    overflow: hidden;
    cursor: pointer;
    /* 클릭 가능하다는 표시 */
    padding: 2px 4px;
    /* 클릭 영역 확보 */
    border-radius: 8px;
    transition: background-color 0.2s;
}

.location-info:hover {
    background-color: #f1f5f9;
    /* 마우스 올렸을 때 강조 */
}

.dark-mode .location-info:hover {
    background-color: #334155;
}

.location-name {
    font-weight: 700;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    color: var(--text-color);
}

.location-name .seq {
    color: var(--primary);
    font-weight: 800;
    margin-right: 2px;
}

.location-coords {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 6px;
    display: block;
    font-family: monospace;
}

.item-actions {
    display: flex;
    gap: 8px;
    margin-left: 8px;
}

.icon-btn {
    background: #f1f5f9;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: #e2e8f0;
    color: var(--text-color);
}

.icon-btn.delete {
    color: var(--text-muted);
}

.icon-btn.delete:hover {
    background: #fee2e2;
    color: var(--danger);
}

/* 하단 삭제 / 조절 버튼 구역 */
.bottom-actions {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    flex-shrink: 0;
    margin-top: auto;
    /* Flexbox의 특징을 살려 부모 기준 항상 맨 아래 풋터처럼 강제 고정 */
    /* 모바일에서 버튼들이 좁아지면 두 줄로 내려갈 수 있게 처리 */
}

.action-btn {
    flex: 1;
    min-width: 80px;
    /* 버튼의 최소 너비 방어 */
    padding: 12px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 12px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.action-btn.capture {
    background: #ffe3e3;
    /* 은은한 붉은색 배경 */
    border-color: #ffc9c9;
    color: var(--primary);
}

.action-btn.capture:hover {
    background: #ffc9c9;
}

.action-btn:hover {
    background: #f8fafc;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}

.action-btn.danger {
    color: var(--danger);
    border-color: #fecaca;
    background: #fff5f5;
}

.action-btn.danger:hover {
    background: #fee2e2;
    border-color: #fca5a5;
}

/* 메인 지도 영역 비율 맞추기 */
.map-container {
    flex: 1;
    position: relative;
    background: #e2e8f0;
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* 지도 위 플로팅 버튼 (내 위치 이동) */
.map-floating-btn {
    position: absolute;
    right: 12px;
    bottom: 100px; /* 줌 컨트롤(Leaflet) 위에 배치되도록 높이 조정 */
    width: 44px;
    height: 44px;
    background-color: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    outline: none;
}

.map-floating-btn:hover {
    transform: scale(1.1);
    background-color: var(--bg-color);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.map-floating-btn:active {
    transform: scale(0.95);
}

.map-floating-btn .icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary); /* GPS 아이콘은 강조색인 primary 적용 */
}

.map-floating-btn .icon svg {
    width: 24px;
    height: 24px;
}

/* 내 위치 표시 마커 (깜빡이는 빨간 점) */
.user-location-marker {
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-location-dot {
    width: 12px;
    height: 12px;
    background-color: #e63946;
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(230, 57, 70, 0.5);
    position: relative;
    z-index: 2;
}

.user-location-pulse {
    position: absolute;
    width: 30px;
    height: 30px;
    background-color: rgba(230, 57, 70, 0.4);
    border-radius: 50%;
    animation: location-pulse 2s infinite ease-out;
    z-index: 1;
}

@keyframes location-pulse {
    0% {
        transform: scale(0.5);
        opacity: 1;
    }
    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

/* 모바일 대응: 바텀시트가 올라왔을 때 버튼 위치 조정 */
@media (max-width: 768px) {
    .map-floating-btn {
        bottom: 170px; /* 기본값 (접힌 상태 기준) */
        right: 16px;
        width: 46px;
        height: 46px;
        z-index: 2100; /* Sidebar(2000)보다 높게 설정하여 가려지지 않게 함 */
        transition: bottom 0.4s cubic-bezier(0.19, 1, 0.22, 1);
    }

    /* 사이드바(편집기) 상태에 따라 버튼의 높이를 유동적으로 변경 */
    /* 1. 기본 상태 (중간 높이: 60%) */
    #sidebar:not(.collapsed):not(.expanded) ~ .map-container .map-floating-btn {
        bottom: calc(60% + 20px);
    }

    /* 2. 확장 상태 (전체 높이: 92%) */
    #sidebar.expanded ~ .map-container .map-floating-btn {
        bottom: calc(92% - 80px); /* 헤더 영역 바로 아래쪽에 위치하도록 조정 */
    }
}


/* 지도 위에 뜨는 마커 스타일 조절 (초고가형 디자인) */
.custom-marker-label {
    display: inline-flex;
    align-items: center;
    background: #ffffff;
    border-radius: 30px;
    /* 완전한 알약(Pill) 모양 */
    padding: 6px 14px 6px 6px;
    /* 왼쪽 숫자 뱃지를 위해 여백 세밀 조정 */
    width: max-content;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.05);
    /* 투박한 테두리 대신 우아한 그림자와 헤어라인 보더 */
    transform: translate(-50%, -100%);
    /* 좌표 기준으로 말풍선을 정확히 정중앙 위로 띄움 */
    margin-top: -12px;
    /* 마커 점과 살짝 간격을 둠 */
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s;
    /* 통통 튀는 애니메이션 */
    cursor: pointer;
}

.custom-marker-label:hover {
    transform: translate(-50%, -105%) scale(1.04);
    box-shadow: 0 10px 25px rgba(230, 57, 70, 0.2);
    z-index: 1000 !important;
}

/* 숫자 배지 (원형 -> 여러 숫자 병합 시 긴 캡슐형으로 자동 대응) */
.custom-marker-label .marker-seq {
    background: var(--primary);
    color: #ffffff;
    min-width: 24px;
    /* 가변 길이를 위해 폭 고정 해제 및 최소폭 설정 */
    height: 24px;
    padding: 0 6px;
    /* 글자가 많아질 때를 대비한 좌우 여백 */
    border-radius: 12px;
    /* 숫자가 길어져도 아름다운 타원형 유지 */
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 12px;
    margin-right: 8px;
    box-shadow: 0 2px 6px rgba(230, 57, 70, 0.4);
}

/* 지명 텍스트 */
.custom-marker-label .marker-name {
    color: var(--text-color);
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    letter-spacing: -0.3px;
}

.leaflet-popup-content-wrapper {
    border-radius: 16px;
    font-family: inherit;
    padding: 4px;
}

.leaflet-popup-content b {
    color: var(--primary);
    font-size: 15px;
    display: block;
    margin-bottom: 4px;
}

/* ------------------ 반응형 및 신규 기능 (Mobile & Dark Mode & Toolbar) ------------------ */

/* 툴바 기능 섹션 */
.tool-actions {
    display: flex;
    gap: 8px;
    padding: 0 20px 16px;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.tool-btn {
    flex: 1;
    padding: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
    white-space: nowrap;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
}

.tool-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.tool-btn.primary {
    background: var(--primary);
    border-color: var(--primary-hover);
}

.tool-btn.primary:hover {
    background: var(--primary-hover);
}

/* 툴팁 기본 제거 */
.tooltip {
    cursor: pointer;
}

/* 모바일 전용 핸들 기본은 숨김 */
.bottom-sheet-handle {
    display: none;
}

/* 다크모드 테마 재정의 */
body.dark-mode {
    --bg-color: #0f172a;
    --sidebar-bg: rgba(30, 41, 59, 0.85);
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #334155;
    background-color: var(--bg-color);
}

body.dark-mode .sidebar {
    background: var(--sidebar-bg);
}


/* CSS 반전을 통한 구글맵 고화질 다크모드 처리 (사용자 요청 밝기/대비 비율 반영) */
body.dark-mode .leaflet-tile-pane {
    filter: invert(100%) hue-rotate(180deg) brightness(80%) contrast(100%);
}

body.dark-mode .search-container,
body.dark-mode .bottom-actions,
body.dark-mode .location-item,
body.dark-mode .action-btn {
    background-color: #1e293b;
    color: var(--text-color);
    border-color: var(--border-color);
}

body.dark-mode .search-container {
    background-color: transparent;
}

body.dark-mode .bottom-actions {
    background: #0f172a;
}

body.dark-mode #location-input {
    background-color: #0f172a;
    color: #f1f5f9;
    border-color: #334155;
}

body.dark-mode #location-input:focus {
    border-color: var(--primary);
    background-color: #1e293b;
}

body.dark-mode .location-item:hover {
    border-color: #475569;
    background: #1e293b;
}

body.dark-mode .icon-btn {
    background: #0f172a;
    color: #94a3b8;
}

body.dark-mode .icon-btn:hover {
    background: #334155;
    color: #e2e8f0;
}

body.dark-mode .stats {
    background-color: #0f172a;
    border-color: #334155;
    color: var(--primary);
}

@keyframes slideUpToast {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

body.dark-mode .custom-marker-label {
    background: #1e293b;
    color: #f1f5f9;
    border-color: #334155;
}

/* 모바일 바텀시트 동작 (Media Query Override) */
@media (max-width: 768px) {
    #app {
        flex-direction: column-reverse;
        position: relative;
    }

    .sidebar {
        position: absolute;
        bottom: 0;
        left: 0;
        z-index: 2000;
        width: 100vw;
        height: 60%;
        transition: height 0.4s cubic-bezier(0.19, 1, 0.22, 1), transform 0.4s cubic-bezier(0.19, 1, 0.22, 1), background-color 0.3s;
        transform: translateY(0);
        border-radius: 24px 24px 0 0;
        border-right: none;
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.15);
        display: flex;
        flex-direction: column;
        overflow: hidden;
        /* 곡선 밖으로 핸들이 튀어나오지 않게 깔끔하게 마무리 */
        background: var(--sidebar-bg);
    }

    /* 닫힌 상태 */
    .sidebar.collapsed {
        transform: translateY(calc(100% - 150px));
        /* 높이를 여유 있게 확보하여 버튼이 잘리지 않게 함 */
        background: rgba(255, 255, 255, 0.98);
        /* 닫혔을 때는 배경 불투명도를 높여 명확하게 */
    }

    /* 최대 확장 상태 (화면 상단까지 펼침) */
    .sidebar.expanded {
        height: 92%;
        border-radius: 16px 16px 0 0;
    }

    body.dark-mode .sidebar.collapsed {
        background: rgba(15, 23, 42, 0.98);
    }

    /* 닫힌 상태 가림 처리 */
    .sidebar.collapsed .tool-actions,
    .sidebar.collapsed .search-container,
    .sidebar.collapsed .list-header,
    .sidebar.collapsed .location-list {
        opacity: 0;
        pointer-events: none;
        visibility: hidden;
        transition: opacity 0.2s;
    }

    /* 핸들을 헤더 위에 완전히 자연스럽게 오버레이 */
    .bottom-sheet-handle {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 24px;
        cursor: grab;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        background: transparent;
        /* 배경 투명 (아래 헤더가 보임) */
        z-index: 10;
    }

    .bottom-sheet-handle:active {
        cursor: grabbing;
    }

    .bottom-sheet-handle span {
        display: block;
        width: 44px;
        height: 5px;
        background-color: rgba(255, 255, 255, 0.25);
        /* 어두운 헤더 위에서 빛나게 */
        border-radius: 3px;
        pointer-events: none;
    }

    /* 헤더: 여백을 밀어올려 핸들의 바탕이 되게 함 */
    .sidebar-header {
        padding: 24px 20px 16px;
        /* 상단 24px은 핸들 자리 */
        border-radius: 24px 24px 0 0;
        margin-top: 0;
        background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    }

    /* 하단 버튼 블록 */
    .bottom-actions {
        padding: 12px 20px;
        transition: all 0.3s ease;
    }

    /* 닫혔을 때 버튼들 플로팅(위로 떠오름) 처리 */
    .sidebar.collapsed .bottom-actions {
        position: absolute;
        top: 80px;
        /* 헤더의 실제 높이에 맞춰 여유 있게 아래로 내림 */
        left: 0;
        width: 100%;
        background: transparent;
        border-top: none;
        padding: 8px 16px;
        z-index: 5;
        display: flex;
        justify-content: center;
        gap: 8px;
    }

    /* 닫힌 상태에서의 돋보이는 액션 버튼 테마 */
    .sidebar.collapsed .bottom-actions .action-btn {
        background: #ffffff;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
        border: 1px solid rgba(0, 0, 0, 0.05);
        flex: 1;
    }

    body.dark-mode .sidebar.collapsed .bottom-actions .action-btn {
        background: #1e293b;
        border-color: rgba(255, 255, 255, 0.1);
        color: white;
    }

    .action-btn {
        padding: 12px 8px;
        font-size: 13px;
        border-radius: 12px;
        font-weight: 700;
    }

    /* 맵 컨테이너 및 기타 폼 조절 */
    .map-container {
        position: absolute;
        top: 0;
        left: 0;
        height: 100vh;
        width: 100vw;
    }

    .search-container {
        padding: 16px 20px 12px;
    }

    #location-input {
        padding: 12px 90px 12px 14px; /* 모바일에서도 내부 버튼 공간 확보 */
        font-size: 15px; /* iOS 자동 줌 방지 */
    }

    #add-btn {
        right: 5px;
        top: 5px;
        bottom: 5px;
        padding: 0 14px;
    }

    .tool-actions {
        padding: 10px 16px 16px;
        gap: 6px;
    }

    .tool-btn {
        font-size: 12px;
        padding: 10px 4px;
    }
}

/* ----------------------------------------------------
   단축키 헬퍼 모달 및 버튼 UI
---------------------------------------------------- */
/* ----------------------------------------------------
   단축키 헬퍼 모달 및 버튼 UI
---------------------------------------------------- */
.top-right-tools {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    gap: 10px;
}

.shortcut-helper-btn {
    background: linear-gradient(135deg, #e63946 0%, #a4161a 100%);
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.2s;
}

.shortcut-helper-btn:hover {
    background: linear-gradient(135deg, #d62828 0%, #660708 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(230, 57, 70, 0.4);
}

.shortcut-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
    display: none;
    /* JS에서 flex로 전환 */
    align-items: center;
    justify-content: center;
    z-index: 3000;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.shortcut-modal-content {
    background: white;
    padding: 32px;
    border-radius: 24px;
    width: 90%;
    max-width: 480px;
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    animation: slideUpModal 0.3s cubic-bezier(0.19, 1, 0.22, 1);
}

/* 대쉬보드 전용 모달 너비 확장 */
.dashboard-content {
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes slideUpModal {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
}

.close-modal:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-color);
}

body.dark-mode .close-modal {
    background: rgba(255, 255, 255, 0.1);
    color: #94a3b8;
}

body.dark-mode .close-modal:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.shortcut-modal h3 {
    margin-bottom: 8px;
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.shortcut-modal p {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 20px;
}

.shortcut-list {
    list-style: none;
    margin-top: 24px;
}

.shortcut-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.shortcut-list li:last-child {
    border-bottom: none;
}

/* 키 조합 영역 (Shift + F 가 밀착되도록 조정) */
.shortcut-keys {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    color: #94a3b8;
}

.shortcut-list kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 30px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0 10px;
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    box-shadow: 0 2px 0 #cbd5e1;
    font-family: inherit;
    margin: 0;
    /* 개별 마진 제거로 공백 방지 */
}

/* 설명 영역 */
.shortcut-desc {
    font-size: 14.5px;
    font-weight: 600;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 다크모드 대응 */
body.dark-mode .shortcut-list li {
    border-bottom-color: rgba(255, 255, 255, 0.05);
}

body.dark-mode .shortcut-list kbd {
    background: #0f172a;
    border-color: #334155;
    color: var(--primary);
    box-shadow: 0 2px 0 #020617;
}

/* ------------------ 대쉬보드 프리미엄 스타일 리뉴얼 ------------------ */
/* ------------------ 모달 공통 프리미엄 스타일 ------------------ */
.shortcut-modal-content {
    max-width: 550px;
    /* 기본 너비 (단축키용) */
    width: 95%;
    max-height: 90vh;
    padding: 32px;
    overflow-y: auto;
    position: relative;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    animation: slideUpModal 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 대쉬보드 전용 너비 확장 */
.dashboard-modal .shortcut-modal-content {
    max-width: 1200px;
}

/* 다크모드 공통 모달 배경/글자색 수정 */
body.dark-mode .shortcut-modal-content {
    background: rgba(15, 23, 42, 0.95);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    color: #f1f5f9;
}

/* 대쉬보드 헤더 영역 (버튼 겹침 수정) */
.dashboard-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 12px;
    padding-right: 56px; /* 닫기 버튼(.close-modal) 자리를 위해 공간 확보 */
}

.dashboard-title {
    margin: 0 !important;
    flex: 1;
}

.refresh-btn {
    flex: none !important;
    padding: 8px 16px !important;
    font-size: 12px !important;
    border-color: #4f46e5 !important;
    color: #4f46e5 !important;
    font-weight: 700 !important;
    border-radius: 10px !important;
}

.refresh-btn:hover {
    background: #4f46e5 !important;
    color: white !important;
}

body.dark-mode .refresh-btn {
    border-color: #818cf8 !important;
    color: #818cf8 !important;
}

body.dark-mode .refresh-btn:hover {
    background: #818cf8 !important;
    color: white !important;
}

.shortcut-modal h3 {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
    padding-right: 44px; /* 닫기 버튼과 겹침 방지 */
    background: linear-gradient(135deg, var(--primary), #ffa3a3);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.shortcut-modal p {
    color: #64748b;
    font-size: 14.5px;
    margin-bottom: 24px;
    font-weight: 500;
}

body.dark-mode .shortcut-modal p {
    color: #94a3b8;
}

/* 통계 그리드 레이아웃 */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stats-card {
    background: white;
    padding: 24px;
    border-radius: 20px;
    border: 1px solid rgba(0, 0, 0, 0.04);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.stats-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.05);
}

.stats-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 8px;
}

.stats-value {
    display: block;
    font-size: 28px;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -1px;
}

/* 차트 및 테이블 그리드 */
.dashboard-charts,
.dashboard-tables {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.chart-item,
.log-table-container {
    background: white;
    padding: 24px;
    border-radius: 22px;
    border: 1px solid rgba(0, 0, 0, 0.04);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
}

.chart-title,
.log-table-container h4 {
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 테이블 디자인 */
.log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.log-table th {
    text-align: left;
    padding: 12px 16px;
    background: #f8fafc;
    color: #64748b;
    font-weight: 600;
    border-bottom: 2px solid #f1f5f9;
}

.log-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    vertical-align: middle;
}

.log-table td small {
    display: block;
    font-size: 11px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    color: #64748b;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    width: fit-content;
}

.log-table tr:hover {
    background: #f8fafc;
}

.log-table code {
    background: #f1f5f9;
    padding: 3px 8px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
}

/* 다크모드 보정 */
body.dark-mode .stats-card,
body.dark-mode .chart-item,
body.dark-mode .log-table-container {
    background: #1e293b;
    border-color: rgba(255, 255, 255, 0.05);
}

body.dark-mode .stats-label {
    color: #94a3b8;
}

body.dark-mode .stats-value {
    color: var(--primary);
}

body.dark-mode .chart-title,
body.dark-mode .log-table-container h4 {
    color: #e2e8f0;
}

body.dark-mode .log-table th {
    background: #0f172a;
    color: #94a3b8;
    border-bottom-color: #334155;
}

body.dark-mode .log-table td {
    color: #cbd5e1;
    border-bottom-color: #334155;
}

body.dark-mode .log-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

body.dark-mode .log-table code {
    background: rgba(230, 57, 70, 0.2);
    color: #ffb3b3;
}

@media (max-width: 1024px) {

    .dashboard-charts,
    .dashboard-tables {
        grid-template-columns: 1fr;
    }

    .dashboard-modal .shortcut-modal-content {
        padding: 20px;
        width: 98%;
    }
}

@media (max-width: 768px) {
    .top-right-tools {
        top: 10px;
        right: 10px;
        flex-direction: column;
        gap: 6px;
    }

    .shortcut-helper-btn {
        padding: 6px 12px;
        font-size: 11px;
    }
}

/* 지도 커스텀 우클릭 메뉴 (컨텍스트 메뉴) */
.map-context-menu {
    position: fixed;
    z-index: 1100;
    /* Leaflet 보다 높게 (보통 1000이 지도) */
    min-width: 200px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    padding: 8px;
    display: none;
    animation: contextMenuAppear 0.15s ease-out;
}

@keyframes contextMenuAppear {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.context-coord-info {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    margin-bottom: 6px;
}

.context-coord-info .label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 2px;
}

.context-coord-info code {
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
}

.context-btn {
    width: 100%;
    padding: 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    text-align: left;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s;
}

.context-btn:hover {
    background: var(--primary);
    color: white;
}

/* 다크모드 */
body.dark-mode .map-context-menu {
    background: rgba(30, 41, 59, 0.95);
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .context-coord-info {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .context-btn {
    color: #f1f5f9;
}