:root {
    --color-primary: #2f6b3f;
    --color-primary-dark: #1e4a29;
    --color-bg: #f5f7f4;
    --color-border: #dfe3dc;
    --color-danger: #c0392b;
    --color-caution: #d68910;
    --color-legal: #2f6b3f;
    --color-unknown: #7f8c8d;
    --header-height: 56px;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    font-family: -apple-system, "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
    background: var(--color-bg);
    color: #222;
    overscroll-behavior: none;
    overflow: hidden;
}

.app-header {
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--header-height);
    background: var(--color-primary-dark);
    color: #fff;
    padding: 0 12px;
    position: relative;
    z-index: 30;
}

.icon-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    line-height: 1;
    padding: 6px 8px;
    cursor: pointer;
    border-radius: 6px;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

.header-titles h1 {
    margin: 0;
    font-size: 18px;
    letter-spacing: 2px;
}

.header-titles .tagline {
    margin: 0;
    font-size: 11px;
    opacity: 0.85;
}

.app-layout {
    position: relative;
    height: calc(100dvh - var(--header-height));
    overflow: hidden;
}

.map-area {
    position: absolute;
    inset: 0;
}

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

/* ===== 모바일: 바텀시트 ===== */
#sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 35;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

#sheet-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

.sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 78vh;
    background: #fff;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    z-index: 40;
    display: flex;
    flex-direction: column;
    transform: translateY(calc(100% - 44px));
    transition: transform 0.28s ease;
}

.sheet.expanded {
    transform: translateY(0);
}

.sheet-handle {
    flex: 0 0 auto;
    width: 100%;
    height: 44px;
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
}

.sheet-handle::before {
    content: "";
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: var(--color-border);
}

.sheet-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 0 16px 20px;
}

.search-box {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.search-box input,
.search-box select,
.search-box button {
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 14px;
}

.search-box button {
    background: var(--color-primary);
    color: #fff;
    border: none;
    cursor: pointer;
}

.search-box button:hover {
    background: var(--color-primary-dark);
}

.list-panel .mountain-item {
    padding: 12px 10px;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 6px;
}

.list-panel .mountain-item:hover {
    background: #eef3ec;
}

.list-panel .mountain-item.active {
    background: var(--color-primary);
    color: #fff;
}

.list-panel .mountain-item .name {
    font-weight: bold;
}

.list-panel .mountain-item .meta {
    font-size: 12px;
    opacity: 0.75;
}

.waypoint-marker {
    font-size: 20px;
    line-height: 24px;
    text-align: center;
    cursor: pointer;
}

.empty-hint {
    color: #999;
    font-size: 13px;
}

.course-item {
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    cursor: pointer;
}

.course-item:hover {
    border-color: var(--color-primary);
}

.course-item .title {
    font-weight: bold;
    margin-bottom: 4px;
}

.course-item .stats {
    font-size: 12px;
    color: #555;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.waypoint-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 6px 0;
    border-bottom: 1px dashed var(--color-border);
}

.badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    color: #fff;
    flex-shrink: 0;
}

.badge.LEGAL { background: var(--color-legal); }
.badge.ILLEGAL { background: var(--color-danger); }
.badge.CAUTION { background: var(--color-caution); }
.badge.UNKNOWN { background: var(--color-unknown); }

section.detail-section {
    margin-bottom: 18px;
}

section.detail-section h3 {
    font-size: 14px;
    margin: 0 0 8px;
    border-bottom: 2px solid var(--color-primary);
    padding-bottom: 4px;
}

/* ===== 데스크톱: 3단 레이아웃 =====
   .map-area는 모바일과 동일하게 position:absolute; inset:0으로 항상
   .app-layout을 꽉 채우고(그리드 트랙 퍼센트 높이 계산에 의존하지 않음),
   좌우 패널만 절대위치로 그 위에 얹는 방식. */
@media (min-width: 900px) {
    .icon-btn {
        display: none;
    }

    #sheet-backdrop {
        display: none;
    }

    .sheet {
        position: absolute;
        top: 0;
        bottom: 0;
        left: auto;
        right: auto;
        width: 300px;
        transform: none;
        max-height: none;
        border-radius: 0;
        box-shadow: none;
        overflow: hidden;
        z-index: 10;
    }

    #sidebar {
        left: 0;
        border-right: 1px solid var(--color-border);
    }

    #detail-panel-sheet {
        right: 0;
        width: 340px;
        border-left: 1px solid var(--color-border);
    }

    .sheet-handle {
        display: none;
    }

    .sheet-body {
        height: 100%;
        padding: 16px;
    }
}
