html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: 'gf_Nanum_Gothic', Arial, Helvetica, sans-serif;
    background: #f5f5f5; /* Match page background to avoid visible white band */
}
#container {
    display: flex;
    height: calc(100vh - 30px);
    height: calc(100dvh - 30px);
    width: 100vw;
    font-family: 'gf_Nanum_Gothic', Arial, Helvetica, sans-serif;
}
#sidebar {
    min-width: 370px;
    max-width: 500px;
    width: 370px;
    height: 100%;
    background: #f5f5f5;
    border-right: 1px solid #ddd;
    box-sizing: border-box;
    overflow-y: auto;
}

/* 공통 브랜드 타이틀 스타일 (H1) */
.brand-title {
    margin: 0 0 10px 0;
    padding: 0;
    font-size: 1.4rem;
    font-weight: 800;
    color: #6109ed;
    letter-spacing: -0.5px;
}
/* 공통 버튼 기본 스타일 */
.btn-primary {
    background: #6109ed;
    color: #fff;
    border: none;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    outline: none;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: #7c3ffd;
}

/* 카메라 검색 버튼 스타일 */
.camera-search-btn {
    border-radius: 24px;
    padding: 16px 32px;
    font-size: 1.2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* PC용 카메라 검색 버튼 (지도 위에 위치) */
#pc-camera-search-btn {
    position: absolute;
    left: 50%;
    top: 10%;
    transform: translate(-50%, -50%);
    z-index: 10;
}

/* PC용 줌 슬라이더 */
#zoom-slider {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 200px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 10;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

#zoom-slider input[type="range"] {
    width: 200px;
    height: 40px;
    transform: rotate(-90deg) translateX(-80px) translateY(-80px);
    background: transparent;
    outline: none;
    -webkit-appearance: none;
    position: relative;
    z-index: 1;
    margin: 0;
}

#zoom-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 28px;
    height: 28px;
    background: #6109ed;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    border: 2px solid white;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E");
    background-size: 16px 16px;
    background-position: center;
    background-repeat: no-repeat;
}

#zoom-slider input[type="range"]::-moz-range-thumb {
    width: 28px;
    height: 28px;
    background: #6109ed;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E");
    background-size: 16px 16px;
    background-position: center;
    background-repeat: no-repeat;
}

#zoom-slider input[type="range"]::-webkit-slider-track {
    width: 100%;
    height: 6px;
    background: #ddd;
    border-radius: 3px;
    border: 1px solid #ccc;
}

#zoom-slider input[type="range"]::-moz-range-track {
    width: 100%;
    height: 6px;
    background: #ddd;
    border-radius: 3px;
    border: 1px solid #ccc;
}

#zoom-value {
    display: none;
}

/* 모바일용 카메라 검색 버튼 (상단 검색바에 위치) */
#camera-search-btn {
    position: static;
    display: block;
    width: 100%;
    margin: 12px 0 0 0;
    transform: none;
    left: auto;
    top: auto;
}

#map {
    position: relative;
    flex: 1;
    height: 100%;
}
.detail-close-btn {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 2rem;
    color: #888;
    cursor: pointer;
    z-index: 100;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}
.detail-close-btn:hover {
    color: #6109ed;
}
/* 상세보기 버튼 공통 스타일 */
.detail-more-btn,
.mobile-detail-more-btn {
    font-size: 0.9rem;
    padding: 8px 16px;
    margin: 12px 20px 0px 0px;
    display: block;
    margin-left: 5%;
    width: 90%;
}
#detail-sidebar {
    position: relative;
    min-width: 390px;
    max-width: 500px;
    width: 390px;
    height: 100%;
    background: #fff;
    border-right: 1px solid #ddd;
    box-sizing: border-box;
    overflow-y: auto;
    box-shadow: 2px 0 8px rgba(0,0,0,0.04);
    z-index: 20;
}
.cctv-item {
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    background: #fff;
    transition: background 0.2s;
}
.cctv-item:hover, .cctv-item:focus {
    background: #f3f0ff;
}
.detail-title {
    font-size: 1.2rem;
    font-weight: bold;
    margin: 0;
    margin-bottom: 12px;
    margin-top: 100px;
    padding: 20px 20px 0 20px;
}
.detail-info {
    font-size: 1rem;
    margin: 0 20px 10px 20px;
    color: #333;
}
.fine-table-section {
    margin: 32px 20px 20px 20px;
    background: #f8f8ff;
    border-radius: 12px;
    padding: 16px 12px 12px 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.fine-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 8px;
    font-size: 1rem;
}
.fine-table th, .fine-table td {
    border: 1px solid #e0e0e0;
    padding: 8px 6px;
    text-align: center;
}
.fine-table th {
    background: #f3f0ff;
    font-weight: bold;
    white-space: nowrap;
}
.fine-table-note {
    font-size: 0.95em;
    color: #555;
    margin-top: 4px;
}
.fine-table-note a {
    color: #6109ed;
    text-decoration: underline;
}

.enforcement-info-section {
    margin: 32px 20px 20px 20px;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 12px;
    padding: 16px 12px 12px 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.enforcement-info-section h4 {
    margin: 0 0 12px 0;
    color: #856404;
    font-size: 1.1rem;
}

.enforcement-info p {
    margin: 8px 0;
    font-size: 0.95rem;
    color: #856404;
    line-height: 1.4;
}

#footer {
  position: fixed; 
  bottom: 0; 
  left: 0; 
  right: 0; 
  height: 30px; 
  background-color: #f8f9fa; 
  border-top: 1px solid #dee2e6; 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  font-size: 0.8rem; 
  color: #6c757d; 
  padding: 0 20px;
}

#my-location-btn {
  position: absolute;
  right: 16px;
  bottom: 50px;
  width: 48px;
  height: 48px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  cursor: pointer;
  z-index: 20;
  padding: 8px;
  border: 2px solid #6109ed;
  transition: box-shadow 0.2s, border-color 0.2s;
}
#my-location-btn:hover {
  box-shadow: 0 4px 16px rgba(97,9,237,0.15);
  border-color: #7c3ffd;
  background: #fff;
}

/* 모바일 ≤768 : 모바일 UI 표시, PC 버튼·줌 슬라이더 숨김 */
@media (max-width: 768px) {
  body {
    display: flex;
    flex-direction: column;
    min-height: 100dvh; /* allow body to own scroll; avoid internal scrollers */
  }

  #container {
    flex: 1 1 auto; /* 남은 공간을 모두 차지하도록 설정 */
    display: flex; /* 자식인 #map이 높이를 100%로 채울 수 있도록 */
    min-height: 0; /* flex 컨테이너에서 스크롤 이슈 방지 */
    height: auto; /* remove fixed calc height on mobile */
  }

  #sidebar,
  #detail-sidebar {
    display: none !important;
  }

  #map { 
    position: static; 
    width: 100%;
    height: 100%; /* 부모인 #container를 꽉 채움 */
  }

  #my-location-btn {
    right: 5dvw;
    bottom: calc(15dvh + var(--ads-bottom, 0px)); /* Lift above anchor ad */
  }

  #mobile-search-bar { 
    display: block !important;
    width: 100vw; 
    box-sizing: border-box;
    padding: 16px 16px 8px 16px;
    background: #f5f5f5;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0; /* 높이가 줄어들지 않도록 설정 */
  }

  .mobile-bar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
  }

  .mobile-province-link {
    margin-left: auto;
    text-decoration: none;
    color: #6109ed;
    font-weight: 800;
    font-size: 0.95rem;
    background: white;
    border: 2px solid #6109ed;
    padding: 6px 12px;
    border-radius: 999px;
  }

  .mobile-province-link:active,
  .mobile-province-link:hover {
    background: #6109ed;
    color: #fff;
  }

  #pc-camera-search-btn,
  #zoom-slider { 
    display: none;
  }     /* 모바일에서 숨김 */

  #footer {
    position: static;
    height: 3dvh; /* 모바일에서 고정 1dvh */
    padding: 0 8px; /* 고정 높이에 맞추어 패딩 축소 */
    overflow: hidden; /* 내용이 넘치면 잘림 */
    flex-wrap: nowrap;
    gap: 0;
  }

  /* 모바일 모달 스타일 */
  #mobile-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
  }
  
  #mobile-modal.show {
    display: flex;
  }
  
  #mobile-modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  }
  
  #mobile-modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 2rem;
    color: #888;
    cursor: pointer;
    z-index: 1001;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
  }
  
  #mobile-modal-close:hover {
    color: #6109ed;
  }
  #mobile-modal-close {
    position: sticky;
    top: 0;
    right: 0;
    float: right;
    background: none;
    border: none;
    font-size: 2rem;
    color: #888;
    cursor: pointer;
    z-index: 1001;
    padding: 12px 16px 0 0;
    line-height: 1;
    transition: color 0.2s;
    display: block;
    margin-left: auto;
  }
  #mobile-modal-close:hover {
    color: #6109ed;
  }
}

/* PC ≥769 : 모바일 바 강제 숨김, PC 버튼 지도 상단 10% 고정 */
@media (min-width: 769px) {
  #mobile-search-bar { 
    display: none !important; 
  }   /* ← 핵심: PC에서 무조건 숨김 */

  #pc-camera-search-btn {
    position: absolute; 
    top: 10%; 
    left: 50%;
    transform: translate(-50%,-50%); 
    z-index: 10;
  }

  #mobile-modal {
    display: none;
  }
}

/* PC 네비게이션 바 */
@media (min-width: 1024px) {
  .region-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 65px;
    height: calc(100vh - 30px); /* 푸터 높이만큼 빼기 */
    background: #fff;
    box-shadow: 2px 0 8px rgba(0,0,0,0.04);
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 200;
    font-family: 'Nanum Gothic', sans-serif;
    border-right: 1px solid #dddddd;
  }
  
  .nav-logo {
    height: 80px;
    width: 100%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 0;
    border-bottom: 1px solid #ddd; /* 로고와 버튼 사이 구분선 */
    cursor: pointer;
  }
  
  .nav-logo-circle {
    width: 48px;
    height: 48px;
    border: 2px solid #6109ed;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
  }
  
  .nav-logo:hover .nav-logo-circle {
    transform: scale(1.05);
    border-color: #7c3ffd;
  }
  
  .nav-logo-circle img {
    width: 28px;
    height: 28px;
    filter: brightness(0) saturate(100%) invert(27%) sepia(51%) saturate(2878%) hue-rotate(246deg) brightness(104%) contrast(97%);
  }
  
  .nav-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    flex: 1 1 auto;
    gap: 8px;
    padding: 20px 8px;
  }
  
  .region-btn {
    width: 100%; 
    height: 70px;
    border: none;
    border-radius: 8px;
    background: #fff; /* 배경과 동일한 색상 */
    color: #333;
    font-size: 0.8rem;
    font-family: 'Nanum Gothic', sans-serif;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: -1px;
    text-decoration: none; /* a 태그 밑줄 제거 */
  }
  
  .region-btn:hover {
    background: #f3f0ff;
    color: #333;
    transform: none;
    text-decoration: none; /* 호버 시에도 밑줄 제거 */
  }
  
  .region-btn.active {
    background: #6109ed;
    color: white;
    text-decoration: none; /* active 상태에서도 밑줄 제거 */
  }
  
  .nav-bottom-space {
    height: 32px;
    width: 100%;
    flex-shrink: 0;
  }
  
  /* PC에서 컨테이너를 네비게이션바만큼 오른쪽으로 이동 */
  #container {
    margin-left: 65px;
    width: calc(100vw - 65px);
    width: calc(100dvw - 65px);
  }
  
  /* 검색창 스타일 조정 - PC에서만 */
  #sidebar .sticky {
    margin-top: 20px !important;
    padding-top: 10px;
  }
  
  #search-input {
    height: 50px !important;
    font-size: 1rem !important;
  }
}

/* 모바일에서는 네비게이션 바 SEO 친화적으로 숨김 */
@media (max-width: 1023px) {
  .region-nav {
    position: absolute;
    height: 0;
    overflow: hidden;
    visibility: hidden;
    pointer-events: none;
  }
}

.search-suggestions {
    position: absolute;
    z-index: 1000;
    background: #fff;
    border: 1px solid #ccc;
    width: 100%;
    max-height: 250px;
    overflow-y: auto;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.suggestion-item {
    padding: 8px;
    cursor: pointer;
}
.suggestion-item:hover {
    background-color: #f2f2f2;
}
.suggestion-item.no-result {
    cursor: not-allowed;
    color: #999;
    font-style: italic;
    background-color: #f8f9fa;
}
.suggestion-item.no-result:hover {
    background-color: #f8f9fa;
}

/* =============================
   Shared layout and components
   ============================= */

/* Shared content containers (list/detail pages) */
.content-container,
.camera-list-container {
    margin-left: 65px;
    padding: 20px;
    height: 100vh;
    overflow-y: auto;
    background: #f5f5f5;
    box-sizing: border-box;
}

@media (max-width: 1024px) {
  .content-container,
  .camera-list-container {
    margin-left: 0;
    height: auto; /* remove fixed full viewport height on mobile */
    min-height: 100dvh;
    overflow: visible; /* let body scroll */
    padding-bottom: calc(20px + var(--ads-bottom, 0px)); /* sync with AdSense bottom padding */
  }
}

/* Shared page title */
.page-title {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 20px;
    color: #333;
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    text-align: center;
}

/* Shared back button group */
.back-buttons {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Shared buttons for content pages */
.back-btn {
    display: inline-block;
    padding: 12px 24px;
    background: #6109ed;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: bold;
    transition: background 0.2s;
}

.back-btn:hover {
    background: #7c3ffd;
    color: white;
    text-decoration: none;
}

.back-btn.secondary {
    background: #8b8b8b;
}

.back-btn.secondary:hover {
    background: #696969;
}

/* Back to map link variant used in list pages */
.back-to-map {
    display: inline-block;
    margin-bottom: 20px;
    padding: 12px 24px;
    background: #6109ed;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: bold;
    transition: background 0.2s;
}

.back-to-map:hover {
    background: #7c3ffd;
    color: white;
    text-decoration: none;
}

/* Shared list cards */
.province-card,
.city-card,
.camera-item-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    transition: all 0.2s;
    border-left: 4px solid #6109ed;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.province-card:hover,
.city-card:hover,
.camera-item-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    transform: translateY(-2px);
    text-decoration: none;
    color: inherit;
}

/* Per-card paddings */
.province-card,
.city-card {
    padding: 20px;
}

.camera-item-card {
    padding: 16px 20px;
}

/* Shared error page base */
.error-container {
    margin-left: 65px;
    padding: 20px;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    box-sizing: border-box;
}

@media (max-width: 1024px) {
  .error-container {
    margin-left: 0;
  }
}

.error-content {
    background: #fff;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    text-align: center;
    max-width: 500px;
    width: 100%;
}

.error-title {
    font-weight: bold;
    color: #333;
    margin-bottom: 16px;
}

.error-message {
    color: #666;
    margin-bottom: 12px;
    line-height: 1.5;
}

.error-description {
    color: #888;
    font-size: 0.9rem;
    margin-bottom: 32px;
    line-height: 1.4;
}

.error-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.error-btn {
    display: inline-block;
    padding: 12px 24px;
    background: #6109ed;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: bold;
    transition: background 0.2s;
    min-width: 200px;
}

.error-btn:hover {
    background: #7c3ffd;
    color: white;
    text-decoration: none;
}

.error-btn.secondary {
    background: #8b8b8b;
}

.error-btn.secondary:hover {
    background: #696969;
}

.error-links {
    margin-top: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
}

.error-link {
    color: #6109ed;
    text-decoration: none;
    font-size: 0.9rem;
}

.error-link:hover {
    text-decoration: underline;
    color: #7c3ffd;
}

@media (max-width: 480px) {
  .error-content {
    padding: 30px 20px;
    margin: 20px;
  }

  .error-icon {
    font-size: 3rem;
  }

  .error-actions {
    gap: 16px;
  }
}
