﻿/* Android WebView textZoom(시스템 글꼴 크기 설정)이 시각적 렌더링만 키워 DOM 측정과 불일치하는
   문제를 차단. 탭 텍스트 2줄 표시 방지. */
html {
    -webkit-text-size-adjust: none;
    text-size-adjust: none;
}

/* 전체 텍스트 선택·복사 방지(무단 복제 방지). 입력 필드는 정상 입력 위해 허용 */
body {
    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}
input, textarea, [contenteditable="true"] {
    -webkit-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* Base Variables */
:root {
    --fscale: 1;
    /* Colors */
    --primary: #4F46E5;
    /* Indigo */
    --primary-light: #818CF8;
    --bg-color: #F8FAFC;
    --surface: #FFFFFF;
    --text-main: #0F172A;
    --text-muted: #64748B;
    --border: #E2E8F0;

    /* Status Colors */
    --status-green: #10B981;
    --status-green-bg: #D1FAE5;
    --status-yellow: #F59E0B;
    --status-yellow-bg: #FEF3C7;
    --status-red: #EF4444;
    --status-red-bg: #FEE2E2;

    /* Metrics */
    --border-radius: 16px;
    --border-radius-lg: 24px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-glass: 0 8px 32px 0 rgba(31, 38, 135, 0.15);

    /* Animation */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, 'Helvetica Neue', 'Segoe UI', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow: hidden;
    /* Prevent body scroll, handle inside views */
    -webkit-font-smoothing: antialiased;
}

/* App Container */
#app {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    position: relative;
    overflow: hidden;
}

/* Views Management */
.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
    z-index: 10;
    background-color: var(--bg-color);
    overflow-y: auto;
}

.view.active {
    opacity: 1;
    pointer-events: auto;
    z-index: 20;
}

/* ------------------ 
   1. Intro View 
------------------ */
#intro-view {
    display: flex;
    flex-direction: column;
    padding: 24px;
    background: linear-gradient(135deg, #f0f4ff 0%, #ffffff 100%);
    position: relative;
    overscroll-behavior-y: contain;
}

.intro-header {
    margin-top: 20px;
    margin-bottom: 16px;
}

.intro-header h1 {
    font-size: calc(var(--fscale) * 32px);
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
    cursor: pointer;
    user-select: none;
}

#ptr-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 0;
    overflow: hidden;
    color: var(--text-muted);
    font-size: calc(var(--fscale) * 18px);
    transition: height 0.2s ease;
    margin: -24px -24px 0;
}

#ptr-indicator i {
    transition: transform 0.2s ease, color 0.2s ease;
}

#ptr-indicator.ptr-ready i {
    transform: rotate(180deg);
    color: var(--primary);
}

.intro-header h1 span {
    color: var(--primary);
}

.intro-header p {
    color: var(--text-muted);
    font-size: calc(var(--fscale) * 16px);
}

.region-cards h2 {
    font-size: calc(var(--fscale) * 18px);
    font-weight: 700;
    margin-bottom: 12px;
}

.cards-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}


/* city-step: step-hidden일 때는 숨김 유지, 보일 때만 flex */
#city-step:not(.step-hidden) {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.card {
    position: relative;
    border-radius: var(--border-radius);
    overflow: hidden;
    height: 120px;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.card:active {
    transform: translateY(0);
}

.card-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    transition: transform 0.5s ease;
}

.card:hover .card-bg {
    transform: scale(1.05);
}

/* 권역카드·지역카드·장면전환 배경은 Supabase Storage에서 관리 (index.js STORAGE_BASE 참조) */

/* Level 1: 권역 그룹 카드 */
.group-cards-container {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: repeat(6, 1fr);
    gap: 3px;
    height: calc(100dvh - 170px);
    overflow: hidden;
    border-radius: 12px;
}

.group-card {
    position: relative;
    border-radius: 0;
    overflow: hidden;
    cursor: default;
    background: var(--surface);
    border: none;
    display: flex;
    align-items: center;
}

.group-card.available {
    cursor: pointer;
    border: none;
    box-shadow: none;
    transition: var(--transition);
}

.group-card.available:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.group-card.available:active {
    transform: translateY(0);
}

.group-card-content {
    position: relative;
    z-index: 1;
    padding: 8px 10px;
    width: 100%;
}

/* 활성 권역 카드: 콘텐츠를 카드 하단에 고정 높이로 절대 위치 (block 레이아웃)
   → h3(권역명)가 p(지역명) 줄 수에 상관없이 모든 카드에서 동일한 높이에 표시됨 */
.group-card .group-card-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    width: auto;
    height: 90px; /* 권역명 위치(준비중 카드 포함 동일). 살짝 내림: 94→90 */
    padding: 8px 10px;
    overflow: hidden;
}

.group-card.available .group-card-content h3 {
    color: #fff;
    font-size: calc(var(--fscale) * 15px);
    font-weight: 700;
    margin-bottom: 2px;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.group-card.available .group-card-content p {
    color: rgba(255, 255, 255, 0.8);
    font-size: calc(var(--fscale) * 10px);
    word-break: keep-all;
    overflow: hidden;
}

.group-card:not(.available) .group-card-content h3 {
    color: #fff;
    font-size: calc(var(--fscale) * 15px);
    font-weight: 700;
    margin-bottom: 2px;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.coming-badge {
    display: inline-block;
    font-size: calc(var(--fscale) * 10px);
    background: rgba(0, 0, 0, 0.45);
    color: rgba(255, 255, 255, 0.9);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}

/* Level 2: 도시 선택 헤더 */
.city-step-header {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 16px;
}

.city-step-header h2 {
    font-size: calc(var(--fscale) * 18px);
    font-weight: 700;
}

#btn-back-group {
    background: none;
    border: none;
    font-size: calc(var(--fscale) * 18px);
    color: var(--text-main);
    cursor: pointer;
    padding: 4px 10px 4px 0;
}

/* 도시 카드 (disabled) */
.region-card.disabled-card {
    cursor: default;
    box-shadow: none;
    border: 1px solid var(--border);
}

.region-card.disabled-card:hover {
    transform: none;
    box-shadow: none;
}

.disabled-card .card-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.disabled-card .card-content h3 {
    color: var(--text-muted);
    font-weight: 600;
}

.disabled-card:has(.card-bg) .card-content h3 {
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

.step-hidden {
    display: none;
}

.card-tag {
    position: absolute;
    top: 12px;
    right: 12px;
    background-color: var(--primary);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: calc(var(--fscale) * 11px);
    font-weight: 700;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.card-content h3 i {
    margin-right: 6px;
    font-size: calc(var(--fscale) * 18px);
    vertical-align: middle;
    opacity: 0.9;
}

.card-content {
    position: absolute;
    bottom: 0;
    left: 0;
    padding: 16px;
    width: 100%;
    color: white;
}

.card-content h3 {
    font-size: calc(var(--fscale) * 20px);
    font-weight: 700;
    margin-bottom: 4px;
}

.card-content p {
    font-size: calc(var(--fscale) * 13px);
    opacity: 0.9;
}

/* ------------------ 
   2. Transition View 
------------------ */
#transition-view {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--text-main);
    color: white;
    text-align: center;
}

.transition-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    opacity: 0.4;
    filter: blur(4px);
}

.transition-content {
    position: relative;
    z-index: 2;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
    margin: 0 auto 24px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.transition-content h2 {
    font-size: calc(var(--fscale) * 24px);
    font-weight: 600;
    line-height: 1.4;
}

/* ------------------ 
   3. Map View 
------------------ */
#map-view {
    overflow: hidden;
}

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

.top-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
}

.top-bar h2 {
    font-size: calc(var(--fscale) * 16px);
    font-weight: 600;
}

.top-bar-btns {
    display: flex;
    gap: 8px;
}

.top-bar button {
    background: none;
    border: none;
    font-size: calc(var(--fscale) * 20px);
    color: var(--text-main);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.top-bar button:active {
    background-color: rgba(0, 0, 0, 0.05);
}

/* ------------------ 
   Side Menu 
------------------ */
.side-menu {
    position: absolute;
    top: 0;
    right: -280px;
    width: 280px;
    height: 100%;
    background-color: var(--surface);
    z-index: 2100;
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.1);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.side-menu.show {
    right: 0;
}

.menu-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 2050;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.menu-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.menu-header {
    padding: 24px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding-top: calc(24px + env(safe-area-inset-top, 0px));
}

.menu-header h3 {
    font-size: calc(var(--fscale) * 18px);
    font-weight: 700;
}

#close-menu-btn {
    background: none;
    border: none;
    font-size: calc(var(--fscale) * 20px);
    color: var(--text-muted);
    cursor: pointer;
}

.menu-list {
    list-style: none;
    padding: 12px 0;
}

.menu-list li {
    padding: 16px 20px;
    font-size: calc(var(--fscale) * 15px);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.menu-list li i {
    width: 24px;
    text-align: center;
    color: var(--text-muted);
}

.menu-list li:hover {
    background-color: var(--bg-color);
}

.menu-list li:active {
    background-color: var(--border);
}

.menu-divider {
    height: 1px;
    background-color: #ccc;
    margin: 4px 16px;
    padding: 0 !important;
    pointer-events: none;
    cursor: default;
}
.menu-divider:hover, .menu-divider:active {
    background-color: #ccc !important;
}

/* ── 검색창 ── */
#search-wrap {
    position: absolute;
    top: 64px; /* fallback — JS가 top-bar 실측값으로 덮어씀 */
    left: 12px;
    right: 12px;
    z-index: 2001; /* 상세패널(2000)보다 위 — 드롭다운이 패널에 가리지 않게 */
}

#search-bar {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 10px 14px;
    gap: 10px;
    box-shadow: var(--shadow-md);
}

.search-icon {
    color: var(--text-muted);
    font-size: calc(var(--fscale) * 14px);
    flex-shrink: 0;
}

#search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: calc(var(--fscale) * 14px);
    font-family: inherit;
    background: transparent;
    color: var(--text-main);
    min-width: 0;
}

#search-input::placeholder {
    color: var(--text-muted);
}

#search-clear {
    display: none;
    background: none;
    border: none;
    color: #c2c6cc;   /* 단지 필요예산 검색창 X와 동일(원형 xmark) */
    cursor: pointer;
    padding: 0 2px;
    font-size: calc(var(--fscale) * 17px);
    line-height: 1;
    flex-shrink: 0;
}
#search-clear:active { color: #8a9099; }

#search-dropdown {
    list-style: none;
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    margin-top: 5px;
    max-height: 260px;
    overflow-y: auto;
    display: none;
    -webkit-overflow-scrolling: touch;
}

#search-dropdown.open {
    display: block;
}

.search-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.search-item:last-child {
    border-bottom: none;
}

.search-item:active {
    background: var(--bg-color);
}

.search-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

.search-dot.green  { background: var(--status-green); }
.search-dot.yellow { background: var(--status-yellow); }
.search-dot.blue   { background: #6366F1; }
.search-dot.orange { background: #F97316; }

.search-item-info { flex: 1; min-width: 0; }

.search-item-name {
    font-size: calc(var(--fscale) * 14px);
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-item-sub {
    font-size: calc(var(--fscale) * 11px);
    color: var(--text-muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-no-result {
    padding: 16px;
    text-align: center;
    font-size: calc(var(--fscale) * 13px);
    color: var(--text-muted);
}

.search-divider {
    padding: 6px 14px 4px;
    font-size: calc(var(--fscale) * 11px);
    font-weight: 700;
    color: var(--text-muted);
    background: var(--bg-color);
    letter-spacing: 0.04em;
    border-top: 1px solid var(--border);
}

.search-item-cross {
    background: #fafafa;
}

.search-region-btn {
    flex-shrink: 0;
    padding: 4px 10px;
    font-size: calc(var(--fscale) * 12px);
    font-weight: 600;
    border: 1px solid var(--primary);
    color: var(--primary);
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
}

.search-region-btn:active {
    background: var(--primary);
    color: #fff;
}

/* 지역 이동 모달 */
/* ── 위치 권한 안내 모달 ───────────────────────────────────────── */
#loc-perm-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 9100;
    display: none;
    align-items: center;
    justify-content: center;
}
#loc-perm-modal.open { display: flex; }
#loc-perm-modal .lpm-box {
    background: #1f2937;
    border-radius: 18px;
    padding: 28px 24px 20px;
    margin: 20px;
    max-width: 320px;
    width: 100%;
    text-align: center;
}
#loc-perm-modal .lpm-title {
    color: #f3f4f6;
    font-size: calc(var(--fscale) * 16px);
    font-weight: 700;
    margin-bottom: 10px;
}
#loc-perm-modal .lpm-desc {
    color: #9ca3af;
    font-size: calc(var(--fscale) * 14px);
    line-height: 1.65;
    margin-bottom: 22px;
    white-space: pre-line;
}
#loc-perm-modal .lpm-btns {
    display: flex;
    gap: 12px;
}
#loc-perm-modal .lpm-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 12px;
    font-size: calc(var(--fscale) * 15px);
    font-weight: 600;
    cursor: pointer;
}
#loc-perm-modal .lpm-btn-close { background: #374151; color: #d1d5db; width: 100%; }

#region-switch-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 9000;
    display: none;
    align-items: center;
    justify-content: center;
}

#region-switch-modal.open {
    display: flex;
}

#region-switch-modal .rsm-box {
    background: #1f2937;
    border-radius: 18px;
    padding: 28px 24px 20px;
    margin: 20px;
    max-width: 320px;
    width: 100%;
    text-align: center;
}

#region-switch-modal .rsm-msg {
    color: #f3f4f6;
    font-size: calc(var(--fscale) * 15px);
    line-height: 1.6;
    margin-bottom: 22px;
}

#region-switch-modal .rsm-btns {
    display: flex;
    gap: 12px;
}

#region-switch-modal .rsm-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 12px;
    font-size: calc(var(--fscale) * 15px);
    font-weight: 600;
    cursor: pointer;
}

#region-switch-modal .rsm-btn-yes   { background: var(--primary); color: #fff; }
#region-switch-modal .rsm-btn-close { background: #374151; color: #d1d5db; }

.legend {
    position: absolute;
    top: 128px; /* fallback — JS가 실측값으로 덮어씀 */
    right: 16px;
    z-index: 1000;
    padding: 12px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.glass-panel {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: var(--shadow-glass);
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.legend-item {
    display: flex;
    align-items: center;
    font-size: calc(var(--fscale) * 12px);
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: color 0.15s;
}
/* 클릭으로 끈 항목: 글씨·동그라미 회색 + 해당 마커 숨김(필터) */
.legend-item.off { color: #9aa0a6; }
.legend-item.off .dot { background-color: #c4c4c4 !important; }

/* ── 마커 첫줄 항목 선택(범례 하단): 전용면적/세대수/준공년도 ── */
.legend-mk-divider { height: 1px; background: rgba(0, 0, 0, 0.08); margin: 2px 0; }
#mk-label-select { position: relative; }
#mk-label-current {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: calc(var(--fscale) * 12px);
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}
#mk-label-current i { font-size:calc(var(--fscale) * 9px); color: #888; transition: transform 0.15s; }
#mk-label-current.open i { transform: rotate(180deg); }
#mk-label-options {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    padding: 4px;
    min-width: 88px;
    z-index: 1100;
}
#mk-label-options.hidden { display: none; }
.mk-label-opt {
    padding: 7px 10px;
    font-size: calc(var(--fscale) * 12px);
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    color: var(--text-main);
}
.mk-label-opt:hover { background: #f2f2f5; }
.mk-label-opt.active { background: #eef0ff; color: var(--primary); font-weight: 700; }

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
    box-shadow: 0 0 0 2px white;
}

/* ── 내 위치 버튼 ──────────────────────────────────────────── */
#my-location-btn {
    position: absolute;
    top: 128px; /* fallback — JS가 검색창 아래로 실측 배치 */
    left: 12px;
    z-index: 1000;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    color: var(--text-main);
    font-size: calc(var(--fscale) * 16px);
    transition: background 0.15s, color 0.15s;
}
#my-location-btn:active { background: rgba(235, 235, 235, 0.97); }
#my-location-btn.active  { color: #16c60c; } /* 위치 추적 중 형광초록 */
#my-location-btn.loading i { animation: myloc-spin 0.8s linear infinite; }
@keyframes myloc-spin { to { transform: rotate(360deg); } }

/* ── 내 위치 마커 ──────────────────────────────────────────────── */
.my-loc-overlay {
    position: relative;
    width: 0;
    height: 0;
    pointer-events: none;
}
/* 위치 점 — 형광초록 */
.my-loc-dot {
    position: absolute;
    left: 0;
    top: 0;
    width: 16px;
    height: 16px;
    margin-left: -8px;
    margin-top: -8px;
    border-radius: 50%;
    background: #39ff14;
    border: 2px solid #fff;
    box-shadow: 0 0 6px rgba(57, 255, 20, 0.8);
}

.dot-green {
    background-color: var(--status-green);
}

.dot-yellow {
    background-color: var(--status-yellow);
}

.dot-red {
    background-color: var(--status-red);
}

.dot-blue {
    background-color: #6366F1;
}

.dot-orange {
    background-color: #F97316;
}

/* Custom Kakao Overlay Marker styles */
.custom-overlay-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;   /* .marker-viewers 배지 절대배치 기준 */
    /* 마커(말풍선+텍스트+꼬리) 확대 — 말꼬리 tip(하단중앙=좌표앵커) 기준.
       모바일 1.15배(기본), PC는 아래 @media에서 1.3배. */
    transform: scale(1.15);
    transform-origin: 50% 100%;
}
/* PC(지도 넓게 보임)는 마커 1.3배 */
@media (min-width: 1024px) {
    .custom-overlay-marker { transform: scale(1.3); }
}
/* 실시간 접속자수 배지 (지역별 1·2등 단지 마커 위, 검정 직사각형) */
.marker-viewers {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 4px;
    white-space: nowrap;
    background: #111;
    color: #fff;
    font-size:calc(var(--fscale) * 10px);
    font-weight: 700;
    line-height: 1;
    padding: 3px 6px;
    border-radius: 3px;            /* 직사각형 */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    z-index: 5;
}
/* 마커 클릭 시 핀이 scale(1.4)로 커지므로 배지도 그만큼 위로 올려 핀을 안 가리게 */
.custom-overlay-marker:has(.marker-active) .marker-viewers {
    margin-bottom: 13px;
}
/* 접속중 배지가 있는 단지는 마커가 겹칠 때 위로 떠서 다른 마커에 가리지 않게.
   (일반 마커 0 < 배지 단지 500 < 클릭된 마커 1000) — 배지 붙고 떼질 때 :has로 자동 적용/해제 */
.custom-overlay-marker:has(.marker-viewers) {
    z-index: 500;
}

/* 사각 말풍선 마커: 2줄 텍스트(가운데정렬) + 하단 정중앙 삼각 말꼬리(핀 tip) */
.marker-pin {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-width: 30px;
    padding: 2px 6px 3px;
    border-radius: 7px;
    position: relative;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    border: 1.5px solid white;
    color: #fff;
    background-color: var(--mk, #F97316);
    transition: var(--transition);
}
/* 첫줄: 사용자가 고른 항목(전용면적/세대수/준공년도) — 회색 + 둘째줄보다 2px 작게 */
.mk-l1 {
    font-size:calc(var(--fscale) * 9px);
    font-weight: 600;
    color: #f0f0f0;
    line-height: 1.05;
    white-space: nowrap;
}
.mk-l1:empty { display: none; }
/* 둘째줄: 대표가격 */
.mk-l2 {
    font-size:calc(var(--fscale) * 11px);
    font-weight: 700;
    line-height: 1.05;
    white-space: nowrap;
}
.mk-l2:empty { display: none; }
/* 말꼬리: 하단 정중앙 삼각형 (말풍선 배경색과 동일) */
.marker-tail {
    width: 0;
    height: 0;
    margin-top: -1px;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 7px solid var(--mk, #F97316);
    filter: drop-shadow(0 1.5px 1px rgba(0, 0, 0, 0.22));
}

/* 색상 범례(유지): 단지=주황 / 분양권=파랑 / 분양중=초록. 말풍선·말꼬리 공통 변수
   --mk = 말풍선/꼬리 색, --neon = 활성 시 테두리를 도는 네온색(분류색보다 진한 톤) */
.marker-green  { --mk: var(--status-green); --neon: #15803d; }
.marker-yellow { --mk: var(--status-yellow); --neon: #b45309; }
.marker-red    { --mk: var(--status-red);    --neon: #b91c1c; }
.marker-blue   { --mk: #6366F1; --neon: #3730a3; }
.marker-orange { --mk: #F97316; --neon: #c2410c; }

.marker-active {
    transform: scale(1.25);   /* 선택 시 확대(과하지 않게) */
    z-index: 1000 !important;
}

/* 활성 마커: 네온사인이 사각 테두리를 따라 빙글빙글 회전.
   conic-gradient의 시작각(--mk-angle)을 0→360 보간 → 밝은 호가 고정된 사각 테두리를 일주.
   gradient-border 마스크로 테두리 띠만 남기고 가운데는 비움(텍스트 안 가림). */
@property --mk-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}
.marker-pin::before {
    content: '';
    position: absolute;
    inset: -2.5px;
    border-radius: 9px;
    padding: 2.5px;
    background: conic-gradient(from var(--mk-angle),
        transparent 0deg,
        var(--neon, #c2410c) 38deg,
        var(--neon, #c2410c) 66deg,
        transparent 104deg,
        transparent 360deg);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
            mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    filter: drop-shadow(0 0 3px var(--neon, #c2410c)) drop-shadow(0 0 5px var(--neon, #c2410c));
    opacity: 0;
    pointer-events: none;
}
.marker-pin.marker-active::before {
    opacity: 1;
    animation: mk-neon-run 1.25s linear infinite;
}
@keyframes mk-neon-run {
    to { --mk-angle: 360deg; }
}

/* 말풍선(위) + 말꼬리(아래) 세로 스택 컨테이너 */
.marker-pin-box {
    display: flex;
    flex-direction: column;        /* 말풍선 위 + 말꼬리 아래 */
    align-items: center;
    justify-content: center;
}

/* ------------------ 
   4. Bottom Sheet 
------------------ */
.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--surface);
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
    padding: 0 24px 12px;
    z-index: 1001;
    box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.1);
    transform: translateY(110%);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1), visibility 0s linear 0.4s;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    touch-action: auto;
    /* 숨김 상태에선 hit-test에서 완전 제외: 삼성 인터넷/구 WebView는 position:fixed +
       transform 요소의 터치 판정을 transform '적용 전' 박스(여기선 bottom:0의 화면
       하단 strip)로 하므로, translateY(110%)로 화면 밖에 밀어내도 phantom 박스가 살아
       그 아래 바텀메뉴(z-index 990)·하단 외부탭을 가로챘다. 일부 기종은 pointer-events:none
       조차 그 버그 경로에서 무시 → bp 팝업처럼 visibility:hidden 으로 렌더트리 hit-test에서
       아예 제외(어떤 WebView도 visibility:hidden 요소엔 터치를 안 보냄). 슬라이드 유지를 위해
       visibility 전환은 슬라이드(0.4s) 끝난 뒤로 지연(transition delay). */
    visibility: hidden;
    pointer-events: none;
}

.bottom-sheet.show {
    transform: translateY(0);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1), visibility 0s;
    visibility: visible;
    pointer-events: auto;
}

/* 지도 하단 예산 바텀메뉴 (z-index < bottom-sheet 1001 → 시트가 올라오면 가려짐) */
.budget-menu {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    display: flex;
    gap: 8px;
    padding: 8px 10px 5px;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 -3px 10px rgba(0, 0, 0, 0.08);
    z-index: 990;
}
.budget-menu-btn {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 9px 6px;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    color: #fff;
    font-family: inherit;
    line-height: 1.15;
    overflow: hidden;
    position: relative;
    box-shadow: 0 3px 8px rgba(79, 70, 229, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.22);
    transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
/* 은은한 상→하 그라데이션 + 상단 하이라이트로 입체감 (primary #4F46E5 계열 톤) */
.budget-menu-btn.bm-1,
.budget-menu-btn.bm-2,
.budget-menu-btn.bm-3,
.budget-menu-btn.bm-4,
.budget-menu-btn.bm-5 { background: linear-gradient(160deg, #7b73e3 0%, #5e57c7 52%, #4f48b8 100%); }
.budget-menu-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 4px rgba(79, 70, 229, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    filter: brightness(.96);
}

/* ── 바텀메뉴 팝업(커뮤니티·지역별 비교분석) — 지도 안개 + 라운드 바가 아래서 둥둥 ── */
#bottom-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.5);
    z-index: 989;                 /* 바텀메뉴(990)·팝업(991)보다 아래 → 지도만 안개 */
    opacity: 0;
    visibility: hidden;
    transition: opacity .3s ease;
}
#bottom-popup-overlay.show { opacity: 1; visibility: visible; }
.bottom-popup {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 72px;                 /* 바텀메뉴 위 */
    display: flex;
    flex-direction: column;       /* 위→아래: 첫 버튼이 맨 위 */
    align-items: center;
    gap: 8px;                     /* 바 사이 간격(너무 크지 않게) */
    padding: 0 12px;
    z-index: 991;
    pointer-events: none;
    visibility: hidden;
    max-height: 70vh;
    overflow-y: auto;
}
.bottom-popup.show { visibility: visible; }
.bp-btn {
    pointer-events: auto;
    flex-shrink: 0;
    display: inline-flex;
    flex-direction: column;       /* 아이콘 위 + 텍스트 아래 (버튼 폭에 맞춤) */
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: #fff;
    border: none;
    border-radius: 14px;
    padding: 11px 6px;            /* 폭은 JS가 버튼 폭으로 설정 */
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
    font-size: calc(var(--fscale) * 12px);
    font-weight: 700;
    color: #333;
    font-family: inherit;
    cursor: pointer;
    line-height: 1.25;
    text-align: center;
    white-space: normal;
    position: relative;
    opacity: 0;
    transform: translateY(16px);
    transition: opacity .3s ease, transform .3s ease;
}
.bottom-popup.show .bp-btn { opacity: 1; transform: translateY(0); }
.bp-btn i { font-size: calc(var(--fscale) * 18px); color: var(--primary, #4f6ef7); }
/* 첫 줄(○○ 아파트)은 한 줄 유지 — 폭 초과 시 JS가 폰트를 줄여 줄넘김 방지 */
.bp-l1 { display: inline-block; white-space: nowrap; }
/* 커뮤니티·투자지표 바: 텍스트 2줄이라 지역별 비교분석 바(1줄)와 높이를 맞추려 폰트·여백·아이콘 축소 */
#community-popup .bp-btn, #invest-popup .bp-btn { padding: 7px 6px; gap: 2px; font-size: calc(var(--fscale) * 11px); }
#community-popup .bp-btn i, #invest-popup .bp-btn i { font-size: calc(var(--fscale) * 15px); }
.bp-btn:active { background: #f0f0f0; }
/* 아래(맨 끝 바)부터 위로 순차 등장 */
.bottom-popup.show .bp-btn:nth-child(6) { transition-delay: 0s; }
.bottom-popup.show .bp-btn:nth-child(5) { transition-delay: .04s; }
.bottom-popup.show .bp-btn:nth-child(4) { transition-delay: .08s; }
.bottom-popup.show .bp-btn:nth-child(3) { transition-delay: .12s; }
.bottom-popup.show .bp-btn:nth-child(2) { transition-delay: .16s; }
.bottom-popup.show .bp-btn:nth-child(1) { transition-delay: .20s; }

/* 모바일(<1024): 토론·Q&A는 커뮤니티 팝업으로 이동 → 사이드 메뉴에선 숨김 */
.menu-list li.menu-community-only { display: none; }
.budget-menu-btn .bm-small { font-size: calc(var(--fscale) * 11px); color: rgba(255,255,255,.88); white-space: nowrap; }
.budget-menu-btn .bm-big { font-size: calc(var(--fscale) * 17px); font-weight: 800; color: #fff; white-space: nowrap; }

.sheet-handle-wrap {
    width: 100%;
    padding: 12px 0;
    display: flex;
    justify-content: center;
    cursor: pointer;
}

.sheet-handle {
    width: 40px;
    height: 5px;
    background-color: #CBD5E1;
    border-radius: 10px;
}

.sheet-header {
    margin-bottom: 20px;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: calc(var(--fscale) * 12px);
    font-weight: 700;
    margin-bottom: 8px;
}

.badge-green {
    background-color: var(--status-green-bg);
    color: #065F46;
}

.badge-yellow {
    background-color: var(--status-yellow-bg);
    color: #92400E;
}

.badge-red {
    background-color: var(--status-red-bg);
    color: #991B1B;
}

.badge-blue {
    background-color: #EEF2FF;
    color: #4338CA;
}

.txn-sil-badge {
    display: inline-block;
    font-size: calc(var(--fscale) * 10px);
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 4px;
    background-color: #EEF2FF;
    color: #4338CA;
    margin-left: 4px;
    vertical-align: middle;
}

.txn-new-badge {
    display: inline-block;
    font-size: calc(var(--fscale) * 10px);
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 4px;
    background: rgba(34,197,94,0.14);
    color: #15803d;
    margin-left: 4px;
    vertical-align: middle;
}
.txn-direct-badge {
    display: inline-block;
    font-size: calc(var(--fscale) * 10px);
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 4px;
    background: rgba(148,163,184,0.18);
    color: #64748b;
    vertical-align: middle;
}

.txn-cancel-badge {
    display: inline-block;
    font-size: calc(var(--fscale) * 10px);
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 4px;
    background: rgba(239,68,68,0.14);
    color: #ef4444;
    vertical-align: middle;
    margin-left: 3px;
}

.sheet-header h3 {
    font-size: calc(var(--fscale) * 22px);
    font-weight: 700;
    margin-bottom: 4px;
}

.btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    font-size: calc(var(--fscale) * 16px);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

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

.btn-primary:hover {
    background-color: #4338CA;
}

.btn-sm {
    padding: 8px 12px;
    font-size: calc(var(--fscale) * 14px);
    border-radius: 8px;
    width: auto;
}

/* ------------------ 
   5. Detail Panel 
------------------ */
.detail-panel {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    z-index: 2000;
    transition: top 0.4s ease-in-out;
    display: flex;
    flex-direction: column;
}

.detail-panel.show {
    top: 0;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
}

.panel-header h3 {
    font-size: calc(var(--fscale) * 18px);
    font-weight: 600;
}

.icon-btn {
    background: none;
    border: none;
    font-size: calc(var(--fscale) * 20px);
    color: var(--text-main);
    cursor: pointer;
    padding: 4px;
}

.panel-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior-y: contain;
}

.detail-section {
    background-color: var(--surface);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.detail-section h4 {
    font-size: calc(var(--fscale) * 16px);
    font-weight: 700;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-section h4 i {
    color: var(--primary);
}

/* Chart Mockup */
.chart-container {
    padding: 10px 0;
}

.chart-mockup {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.bar {
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    font-weight: 600;
    font-size: calc(var(--fscale) * 14px);
}

.bar-price {
    background-color: var(--border);
    width: 70%;
    color: var(--text-main);
}

.bar-value {
    background-color: var(--status-green-bg);
    width: 90%;
    color: #065F46;
}

.chart-desc {
    font-size: calc(var(--fscale) * 14px);
    color: var(--text-muted);
    line-height: 1.5;
    background-color: var(--bg-color);
    padding: 12px;
    border-radius: 8px;
}

/* AI Summary Grid */
.ai-summary-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.summary-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    background-color: var(--bg-color);
    border-radius: 12px;
}

.summary-icon {
    width: 36px;
    height: 36px;
    background-color: var(--primary-light);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.summary-text h5 {
    font-size: calc(var(--fscale) * 13px);
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 600;
}

.summary-text p {
    font-size: calc(var(--fscale) * 14px);
    font-weight: 500;
    line-height: 1.4;
}

/* News List */
.news-list {
    list-style: none;
}

.news-list li {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 12px;
    align-items: center;
}

.news-list li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.news-tag {
    font-size: calc(var(--fscale) * 11px);
    font-weight: 600;
    color: var(--primary);
    background-color: rgba(79, 70, 229, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    flex-shrink: 0;
}

.news-title {
    font-size: calc(var(--fscale) * 14px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Comments */
.detail-section h4 .count {
    background-color: var(--primary);
    color: white;
    font-size: calc(var(--fscale) * 12px);
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 4px;
}

.comment-input-wrap {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.comment-input-wrap input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: calc(var(--fscale) * 14px);
    outline: none;
    transition: var(--transition);
}

.comment-input-wrap input:focus {
    border-color: var(--primary);
}

.comment-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.comment-item {
    display: flex;
    gap: 12px;
}

.comment-avatar {
    width: 32px;
    height: 32px;
    background-color: #E2E8F0;
    color: #94A3B8;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.comment-info {
    font-size: calc(var(--fscale) * 13px);
    margin-bottom: 4px;
}

.comment-info .date {
    color: var(--text-muted);
    font-size: calc(var(--fscale) * 11px);
    margin-left: 6px;
}

.comment-text {
    font-size: calc(var(--fscale) * 14px);
    line-height: 1.5;
    background-color: var(--bg-color);
    padding: 10px 12px;
    border-radius: 0 12px 12px 12px;
    display: inline-block;
}

.menu-ad {
    margin-top: auto;
    padding: 12px 8px;
    border-top: 1px solid var(--border);
    position: relative;
}
.menu-ad-swipe-guard {
    position: absolute;
    inset: 0;
    z-index: 1;
}

#app-version {
    position: absolute;
    bottom: 8px;
    right: 12px;
    font-size: calc(var(--fscale) * 10px);
    color: rgba(0, 0, 0, 0.25);
    letter-spacing: 0.5px;
    pointer-events: none;
    user-select: none;
}

/* Detail page (detail.html, request.html) */
.detail-page {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    background: var(--bg-color);
}

/* Map loading overlay (map.html) */
.map-loading {
    position: absolute;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-bg {
    position: absolute;
    inset: 0;
    background: #1E293B center/cover no-repeat;
}

/* ------------------
   Filter Panel
------------------ */
.filter-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1400;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.filter-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.filter-panel {
    position: absolute;
    bottom: -100%;
    left: 0;
    width: 100%;
    background: var(--surface);
    border-radius: 16px 16px 0 0;
    padding: 0 20px 32px;
    z-index: 1500;
    box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.15);
    transition: bottom 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1);
    padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
    max-height: 80vh;
    overflow-y: auto;
}

.filter-panel.show {
    bottom: 0;
}

.filter-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 0 14px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.filter-panel-header h3 {
    font-size: calc(var(--fscale) * 16px);
    font-weight: 700;
}

.filter-panel-header button {
    background: none;
    border: none;
    font-size: calc(var(--fscale) * 18px);
    cursor: pointer;
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.filter-panel-header button:active {
    background: rgba(0, 0, 0, 0.06);
}

.filter-section {
    margin-bottom: 24px;
}

.filter-section-title {
    font-size: calc(var(--fscale) * 11px);
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-chip {
    padding: 7px 16px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    background: none;
    font-size: calc(var(--fscale) * 13px);
    font-weight: 500;
    cursor: pointer;
    color: var(--text-main);
    transition: all 0.2s;
}

.filter-chip.active {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.filter-price-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: calc(var(--fscale) * 14px);
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 16px;
    background: var(--bg);
    border-radius: 10px;
    padding: 10px 14px;
}

.price-range-sep {
    color: var(--text-muted);
    font-weight: 400;
}

.range-slider-wrap {
    position: relative;
    height: 36px;
    display: flex;
    align-items: center;
    padding: 0 8px;
}

.range-slider-track {
    position: absolute;
    left: 8px;
    right: 8px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
}

.range-slider-fill {
    position: absolute;
    height: 4px;
    background: var(--primary);
    border-radius: 2px;
    pointer-events: none;
}

.range-slider-wrap input[type=range] {
    position: absolute;
    left: 0;
    right: 0;
    width: 100%;
    height: 4px;
    background: transparent;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
    padding: 0;
}

.range-slider-wrap input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    pointer-events: auto;
    border: 2.5px solid #fff;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.25);
}

.range-slider-wrap input[type=range]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    pointer-events: auto;
    border: 2.5px solid #fff;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.25);
}

.filter-active-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary);
    pointer-events: none;
}

.filter-actions {
    display: flex;
    gap: 12px;
    padding-top: 4px;
}

.filter-actions .btn {
    flex: 1;
}

.btn-outline {
    background: none;
    border: 1.5px solid var(--border);
    color: var(--text-main);
    border-radius: var(--border-radius);
    padding: 12px 16px;
    font-size: calc(var(--fscale) * 15px);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-outline:active {
    background: rgba(0, 0, 0, 0.04);
}

/* ── PC 우측 상세 패널 (기본: 숨김) ── */
.right-panel { display: none; }


/* ── 태블릿: 폰 프레임 (768–1023px) ─────────────────────────── */
@media (min-width: 768px) and (max-width: 1023px) {
    #app {
        max-width: 480px;
        height: 850px;
        margin: 20px auto;
        border-radius: 30px;
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
        border: 8px solid #1E293B;
    }
    body {
        display: flex;
        align-items: center;
        justify-content: center;
        background-color: #E2E8F0;
    }

    /* embed 모드(PC 좌측 패널 iframe): 폰 프레임 무효화 */
    html.embed-mode body {
        display: block !important;
        background: var(--bg-color) !important;
    }
    /* PC iframe에서 기본정보 지도 숨김 */
    html.embed-mode #bi-apt-map { display: none !important; }
    html.embed-mode #app {
        max-width: 100% !important;
        width: 100% !important;
        height: 100dvh !important;
        margin: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        border: none !important;
    }
}

/* PC 분할 레이아웃 기본값: 모바일에서 오른쪽 패널 숨김 */
.pc-body-right { display: none; }

/* ══════════════════════════════════════════════════════════════
   PC 레이아웃 (1024px+)
   - 홈(body.page-home): 일반 스크롤 랜딩 페이지
   - 지도·상세 페이지: 풀스크린 (폰 프레임 없음)
══════════════════════════════════════════════════════════════ */
@media (min-width: 1024px) {

    /* ── 공통: 폰 프레임 제거 ── */
    #app {
        max-width: 100%;
        border-radius: 0;
        border: none;
        box-shadow: none;
        margin: 0;
    }

    /* ── 홈 페이지: 풀스크린 고정 레이아웃 ── */
    body.page-home {
        overflow: hidden;
        display: block;
        background: linear-gradient(160deg, #eef2ff 0%, #f8fafc 100%);
        height: 100vh;
    }

    body.page-home #app {
        position: static;
        overflow: hidden;
        height: 100vh;
        width: 100%;
    }

    body.page-home #intro-view {
        position: static;
        opacity: 1;
        pointer-events: auto;
        height: auto;
        overflow: visible;
        padding: 0;
        background: none;
        display: flex;
        flex-direction: column;
        min-height: 100vh;
    }

    /* 모바일 전용 요소 숨김 */
    #ptr-indicator                   { display: none !important; }
    body.page-home .intro-header     { display: none !important; }
    body.page-home #app-version      { display: none !important; }

    /* ── PC 상단 네비게이션 ── */
    .pc-nav {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        padding: 0 60px;
        height: 64px;
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-bottom: 1px solid var(--border);
        position: sticky;
        top: 0;
        z-index: 500;
        flex-shrink: 0;
    }

    .pc-nav-brand {
        display: flex;
        align-items: center;
        gap: 10px;
        cursor: pointer;
        user-select: none;
        font-size: calc(var(--fscale) * 18px);
        font-weight: 800;
        color: var(--text-main);
        letter-spacing: -0.3px;
    }

    .pc-nav-brand i  { color: var(--primary); font-size: calc(var(--fscale) * 20px); }
    .pc-nav-brand em { color: var(--primary); font-style: normal; }

    .pc-nav-right {
        display: flex;
        align-items: center;
        gap: 20px;
    }

    .pc-nav-version {
        font-size: calc(var(--fscale) * 11px);
        color: var(--text-muted);
        letter-spacing: 0.5px;
        background: var(--bg-color);
        padding: 3px 10px;
        border-radius: 20px;
    }

    /* ── PC 히어로 섹션 (오른쪽 패널 내부) ── */
    .pc-hero {
        display: flex !important;
        flex-direction: column;
        justify-content: center;
        align-items: flex-start;
        width: 100%;
        padding: 60px;
        background: linear-gradient(135deg, #eef2ff 0%, #e8edff 55%, #f0f4ff 100%);
        border-bottom: none;
        position: relative;
        overflow: hidden;
    }

    .pc-hero::before {
        content: '';
        position: absolute;
        top: -80px; right: -80px;
        width: 380px; height: 380px;
        border-radius: 50%;
        background: radial-gradient(circle, rgba(79, 70, 229, 0.08) 0%, transparent 70%);
        pointer-events: none;
    }

    .pc-hero-inner {
        max-width: none;
        margin: 0;
        position: relative;
        z-index: 1;
    }

    .pc-hero h1 {
        font-size: calc(var(--fscale) * 46px);
        font-weight: 800;
        line-height: 1.15;
        margin-bottom: 14px;
        letter-spacing: -1.5px;
        color: var(--text-main);
    }

    .pc-hero h1 em { color: var(--primary); font-style: normal; }

    .pc-hero p {
        font-size: calc(var(--fscale) * 18px);
        color: var(--text-muted);
        line-height: 1.6;
        max-width: 560px;
    }

    /* ── 좌우 분할 레이아웃 ── */
    body.page-home .pc-body-split {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        height: calc(100vh - 64px);
        overflow: hidden;
    }

    body.page-home .pc-body-left {
        flex: 0 0 50%;
        max-width: 50%;
        min-width: 0;
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        justify-content: center;
        min-height: 0;
        overflow: hidden;
    }

    body.page-home .pc-body-right {
        display: flex;
        flex: 0 0 50%;
        max-width: 50%;
        min-width: 0;
    }

    /* ── 콘텐츠 래퍼 ── */
    .pc-main-content {
        width: 546px;
        flex-shrink: 0;
        margin: 0;
        padding: 24px 0;
        position: relative; /* city-step 절대 위치 기준점 */
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    .region-cards h2 {
        font-size: calc(var(--fscale) * 16px);
        font-weight: 700;
        margin-bottom: 10px;
        color: var(--text-main);
        flex-shrink: 0;
    }

    body.page-home #group-step {
        display: flex;
        flex-direction: column;
    }

    /* 권역 카드: 3열 (모바일 동일) */
    .group-cards-container {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: auto;
        height: auto;
        max-height: none;
        gap: 3px;
        padding-bottom: 0;
    }

    .group-card,
    .group-card.available { height: 137px; border-radius: 0; }

    .group-card .group-card-content {
        height: 106px; /* 권역명 위치(준비중 카드 포함 동일). 살짝 내림: 112→106 */
    }
    .group-card.available .group-card-content h3 { font-size: calc(var(--fscale) * 20px); white-space: nowrap; }
    .group-card:not(.available) .group-card-content h3 { font-size: calc(var(--fscale) * 20px); white-space: normal; }
    .group-card.available .group-card-content p { font-size: calc(var(--fscale) * 13px); word-break: keep-all; }

    /* 도시 카드: PC에서도 모바일과 동일하게 세로 스크롤 단일 컬럼 */
    .city-step-header { margin-bottom: 24px; }
    .city-step-header h2 { font-size: calc(var(--fscale) * 22px); }


    /* ── PC 푸터 ── */
    .pc-footer {
        display: flex !important;
        align-items: center;
        justify-content: center;
        gap: 10px;
        padding: 18px 60px;
        background: rgba(255, 255, 255, 0.85);
        border-top: 1px solid var(--border);
        font-size: calc(var(--fscale) * 12px);
        color: var(--text-muted);
        flex-shrink: 0;
    }

    .pc-footer-ver {
        font-weight: 700;
        color: var(--primary);
        letter-spacing: 0.5px;
    }

    .pc-footer-sep { color: var(--border); }

    /* ── 상세 페이지: 중앙 정렬 ── */
    .detail-page {
        max-width: 860px;
        margin: 0 auto;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.08);
        min-height: 100vh;
    }

    /* ── 범례: 패널이 좌측이므로 기본 우측 배치 유지 ── */
    .legend {
        right: 16px;
        left: auto;
    }

    /* ── 바텀시트·예산 바텀메뉴: PC에서 비활성 ── */
    .bottom-sheet { display: none !important; }
    .budget-menu { display: none !important; }
    .bottom-popup { display: none !important; }   /* 바텀메뉴 팝업도 PC에선 비활성(바텀메뉴 없음) */
    #bottom-popup-overlay { display: none !important; }
    /* PC에선 토론·Q&A를 사이드 메뉴에 그대로 표시(모바일에서만 커뮤니티 팝업으로 이동) */
    .menu-list li.menu-community-only { display: flex !important; }

    /* ── 좌측 상세 패널 (top·height는 JS positionOverlays에서 설정) ── */
    .right-panel {
        display: block;
        position: absolute;
        top: 120px; /* JS 설정 전 fallback */
        left: 0;
        width: clamp(400px, 32vw, 580px);
        height: calc(100% - 120px);
        background: var(--surface);
        z-index: 2000;
        box-shadow: 4px 4px 24px rgba(0, 0, 0, 0.14);
        border-right: 1px solid var(--border);
        border-radius: 0 0 12px 0;
        transform: translateX(-100%);
        transition: transform 0.38s cubic-bezier(0.4, 0, 0.2, 1);
        overflow: hidden;
    }

    .right-panel.show { transform: translateX(0); }

    .right-panel-iframe {
        width: 100%;
        height: 100%;
        border: none;
        display: block;
    }
}

/* ── 모바일 인트로: 스크롤 차단 (PTR 복구) ── */
@media (max-width: 1023px) {
    #intro-view { overflow-y: hidden; }
}