body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: "Helvetica Neue", Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

/* --- 説明用ポップアップのスタイル --- */
.app-description {
    display: none; /* 初期非表示 */
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 800px;
    background-color: rgba(255, 255, 255, 0.95);
    padding: 20px 40px 20px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    z-index: 2000;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    border: 1px solid #ccc;
    box-sizing: border-box;
}

.description-text {
    text-align: center;
}

#close-desc-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    line-height: 1;
    padding: 5px 10px;
}

#close-desc-btn:hover {
    color: #333;
}

/* 「このマップについて」リンクのスタイル */
.about-map-link {
    display: inline-block;
    margin-bottom: 15px;
    font-size: 13px;
    color: #007bff;
    text-decoration: none;
    border-bottom: 1px dashed #007bff;
    cursor: pointer;
}

.about-map-link:hover {
    color: #0056b3;
    border-bottom-style: solid;
}

/* スマホでの説明ポップアップ調整 */
@media (max-width: 768px) {
    .app-description {
        top: 50%; /* スマホでは中央表示にする */
        transform: translate(-50%, -50%);
        font-size: 13px;
        padding: 15px 35px 15px 15px;
        width: 85%;
        max-height: 80vh;
        overflow-y: auto;
    }
    .description-text {
        text-align: left;
    }
}
/* ----------------------------------- */

.container {
    display: flex;
    height: 100vh;
    width: 100vw;
    flex-direction: row;
}

/* サイドバーの設定 */
#sidebar {
    width: 350px;
    background-color: #f8f9fa;
    border-right: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    z-index: 1000;
    flex-shrink: 0;
}

.controls {
    padding: 15px;
    background-color: #fff;
    border-bottom: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    max-height: 50vh; 
    overflow-y: auto;
}

.controls h2 {
    margin-top: 0;
    font-size: 18px;
    color: #333;
    margin-bottom: 5px; /* リンクが入るため少し詰める */
    line-height: 1.4;
}

.control-group {
    margin-bottom: 10px;
}

.search-box {
    display: flex;
    gap: 5px;
}

.search-box input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 14px;
}

#search-btn {
    padding: 8px 12px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    font-weight: bold;
}

#search-btn:hover {
    background-color: #0056b3;
}

/* フィルタセクションのスタイル */
.filters-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 10px;
}

.filter-section h3 {
    font-size: 12px;
    font-weight: bold;
    color: #666;
    margin: 0 0 5px 0;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px; /* クリックエリアを少し広げる */
    cursor: pointer; /* クリック可能であることを示すカーソル */
    position: relative; /* 矢印アイコンの配置基準 */
    user-select: none; /* テキスト選択を無効化 */
    transition: background-color 0.2s;
}

.filter-section h3:hover {
    background-color: #f9f9f9; /* ホバー時のフィードバック */
}

/* 開閉インジケータ（矢印） */
.filter-section h3::after {
    content: '';
    position: absolute;
    right: 5px;
    top: 50%;
    /* 初期状態：下向き三角（▼） */
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #666;
    transition: transform 0.2s ease;
}

/* 閉じている状態（クラスが付与された場合）の矢印回転（▶） */
.filter-section h3.closed::after {
    transform: translateY(-50%) rotate(-90deg);
}

/* --- 全選択・全解除ボタンのスタイル --- */
.filter-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 5px;
    padding-bottom: 5px;
    border-bottom: 1px dashed #eee;
}

.select-btn {
    font-size: 11px;
    padding: 2px 8px;
    background-color: #f8f9fa;
    border: 1px solid #ced4da;
    border-radius: 12px;
    cursor: pointer;
    color: #495057;
    transition: background-color 0.2s;
}

.select-btn:hover {
    background-color: #e2e6ea;
    border-color: #adb5bd;
}

.checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    font-size: 13px;
    padding: 3px 0;
    cursor: pointer;
}

.checkbox-item:hover {
    background-color: #f0f0f0;
    border-radius: 4px;
}

.checkbox-item input {
    margin-right: 8px;
    cursor: pointer;
}

.checkbox-item label {
    cursor: pointer;
    flex: 1;
    color: #333;
}

.result-count {
    font-size: 12px;
    color: #666;
    text-align: right;
    margin-top: 5px;
}

/* データリストの設定 */
#data-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    scroll-behavior: smooth;
    border-top: 1px solid #ddd;
}

.list-item {
    background: #fff;
    border: 1px solid #eee;
    padding: 12px;
    margin-bottom: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.list-item:hover {
    background-color: #e9ecef;
}

.list-item.active {
    border: 2px solid #007bff;
    background-color: #f0f7ff;
    box-shadow: 0 0 5px rgba(0, 123, 255, 0.3);
}

.list-item h3 {
    margin: 0 0 5px 0;
    font-size: 16px;
    color: #007bff;
}

.list-item p {
    margin: 0;
    font-size: 13px;
    color: #555;
    line-height: 1.5;
}

.badges {
    margin-top: 5px;
    margin-bottom: 5px;
}

.badge {
    display: inline-block;
    padding: 3px 8px;
    font-size: 11px;
    border-radius: 12px;
    color: white;
    margin-right: 3px;
    font-weight: bold;
}

.badge-author { background-color: #43A047; }
.badge-layer { 
    background-color: #17a2b8; 
    text-shadow: 0 0 2px rgba(0,0,0,0.2);
}

/* 地図の設定 */
#map {
    flex: 1;
    height: 100%;
}

/* ポップアップ */
.leaflet-popup-content {
    margin: 10px;
    width: 280px !important;
}
.popup-content h3 {
    margin: 0 0 8px 0;
    font-size: 16px;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
    color: #333;
}
.popup-content img {
    width: 100%;
    height: auto;
    display: block;
    margin: 8px 0;
    border-radius: 4px;
    border: 1px solid #ddd;
}
.popup-content div {
    font-size: 14px;
    line-height: 1.5;
    color: #444;
}
.popup-meta {
    font-size: 12px; 
    color: #777; 
    margin-top: 8px; 
    background: #f9f9f9; 
    padding: 5px; 
    border-radius: 4px;
}

/* カスタムマーカー */
.custom-marker {
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 3px 6px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    transition: transform 0.2s;
}
.custom-marker:hover {
    transform: scale(1.15);
    z-index: 1000 !important;
}
.custom-marker img {
    width: 70%;
    height: 70%;
    object-fit: contain;
    filter: drop-shadow(0 1px 1px rgba(255,255,255,0.8));
}

/* モバイル対応 */
@media (max-width: 768px) {
    .container {
        flex-direction: column-reverse;
    }
    #sidebar {
        width: 100%;
        height: 50%;
        border-right: none;
        border-top: 2px solid #ddd;
        box-shadow: 0 -2px 5px rgba(0,0,0,0.1);
    }
    #map {
        height: 50%;
    }
    .controls {
        padding: 10px;
        max-height: 180px; 
    }
    .filters-container {
        flex-direction: row;
        gap: 10px;
    }
    .filter-section {
        flex: 1;
        overflow-y: auto;
        max-height: 120px;
        background: #fdfdfd;
        border: 1px solid #eee;
        padding: 5px;
        border-radius: 4px;
    }
}