/* =========================================================
   내가 방문한 맛집 지도 — 스타일
   구성: 1) 색·크기 토큰(라이트/다크)  2) 기본  3) 레이아웃
         4) 컴포넌트  5) 지도 위 요소  6) 반응형(맨 아래에 모음)
   ========================================================= */

/* ===== 1) 색·크기 토큰 ===== */
:root {
  color-scheme: light dark;

  /* 크기 */
  --panel-width: 340px;
  --sheet-peek: 108px; /* 모바일 바텀시트가 접혔을 때 보이는 높이 (손잡이+제목+식당 추가) */
  --tap: 44px; /* 버튼·칩 최소 높이 */
  --radius: 14px;
  --radius-sm: 10px;

  /* 따뜻한 라이트 테마 */
  --bg: #f7f3ee;
  --surface: #fffdfb;
  --surface-2: #f4eee7; /* hover, 옅은 배경 */
  --surface-3: #ebe3d9; /* 개수 배지, 눌림 */
  --text: #2b2622;
  --text-muted: #7b6f65;
  --border: #e8dfd4;
  --border-strong: #d6cabd;

  --accent: #d9653b; /* 테라코타 */
  --accent-hover: #c4552d;
  --accent-soft: #fbebe1;
  --accent-text: #a8461f;

  --strong: #2b2622; /* 선택된 칩, 주요 버튼 */
  --strong-hover: #120f0d;
  --on-strong: #fffdfb;

  --danger: #c2412d;
  --danger-soft: #fce9e4;
  --info-text: #6b5200;
  --info-soft: #fff4d6;
  --ok-text: #2f7a4f;
  --warn-text: #a15c00;

  --cluster-sido: rgba(217, 101, 59, 0.94);
  --cluster-sigungu: rgba(72, 96, 122, 0.94);

  --shadow-sm: 0 1px 2px rgba(70, 45, 20, 0.08);
  --shadow-md: 0 6px 20px rgba(70, 45, 20, 0.12);
  --shadow-lg: 0 14px 36px rgba(70, 45, 20, 0.2);

  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard",
    "Noto Sans KR", "Malgun Gothic", sans-serif;
}

/* 다크 테마 */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171412;
    --surface: #211d1a;
    --surface-2: #2a2521;
    --surface-3: #37302a;
    --text: #f2ece5;
    --text-muted: #a99c90;
    --border: #37302a;
    --border-strong: #4b423a;

    --accent: #ee8a5f;
    --accent-hover: #f4a17b;
    --accent-soft: rgba(238, 138, 95, 0.16);
    --accent-text: #f4a682;

    --strong: #f2ece5;
    --strong-hover: #ffffff;
    --on-strong: #1b1714;

    --danger: #f08a78;
    --danger-soft: rgba(240, 138, 120, 0.14);
    --info-text: #f1d27a;
    --info-soft: rgba(255, 214, 102, 0.12);
    --ok-text: #86d6a6;
    --warn-text: #f2b866;

    --cluster-sido: rgba(226, 116, 72, 0.95);
    --cluster-sigungu: rgba(92, 120, 150, 0.95);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 14px 36px rgba(0, 0, 0, 0.55);
  }
}

/* ===== 2) 기본 ===== */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  -webkit-user-select: none;
  user-select: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ===== 3) 레이아웃 (데스크톱) ===== */
/* 지도 칸: 왼쪽 패널을 뺀 나머지. 위에서부터 [필터 바] [지도] */
.map-wrap {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: var(--panel-width);
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* 지도는 필터 바를 뺀 나머지 높이를 채움
   (네이버 지도가 #map의 position을 relative로 바꾸므로, 위치는 바깥 칸이 잡아야 함) */
#map {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}

/* 왼쪽 목록 패널 */
.panel {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--panel-width);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 200;
}

/* 바텀시트 손잡이: 데스크톱에서는 숨김 */
.sheet-handle {
  display: none;
}

.panel__header {
  flex: none;
  padding: 20px 16px 14px;
  border-bottom: 1px solid var(--border);
}

.panel__title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.panel__total {
  padding: 2px 9px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-text);
  background: var(--accent-soft);
  border-radius: 999px;
}

.panel__tools {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.panel__tools .tool-btn {
  flex: 1;
}

/* ===== 4) 컴포넌트 ===== */

/* 공통 버튼 */
.tool-btn {
  min-height: var(--tap);
  padding: 0 14px;
  font-size: 15px;
  font-weight: 650;
  white-space: nowrap;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

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

.tool-btn:active {
  transform: scale(0.98);
}

.tool-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

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

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

/* 작은 수정/삭제 버튼 (터치를 위해 높이는 44px) */
.mini-btn {
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.mini-btn:hover {
  color: var(--text);
  background: var(--surface-2);
}

.mini-btn--danger:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

/* 전체 보기 */
.show-all {
  width: 100%;
  min-height: var(--tap);
  padding: 0 12px;
  font-size: 15px;
  font-weight: 650;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.show-all:hover {
  background: var(--surface-3);
}

.show-all.is-active {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
}

/* 지역 목록 */
.region-list {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0;
  padding: 8px 8px 32px;
  list-style: none;
}

.region-list__empty {
  padding: 24px 12px;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.6;
  text-align: center;
}

.region-list ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* 접힌 지역의 하위 목록은 숨김 */
.region:not(.is-expanded) > .region__children {
  display: none;
}

.region--sigungu {
  margin-left: 12px;
}

.region--sigungu > .region__children {
  padding-left: 20px;
}

.region__row {
  display: flex;
  align-items: center;
  min-height: var(--tap);
  border-radius: var(--radius-sm);
}

.region__row:hover {
  background: var(--surface-2);
}

.region__toggle {
  flex: none;
  width: 36px;
  height: var(--tap);
  padding: 0;
  color: var(--text-muted);
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.region__chevron {
  display: inline-block;
  font-size: 20px;
  line-height: 1;
  transition: transform 0.18s;
}

.region.is-expanded > .region__row .region__chevron {
  transform: rotate(90deg);
}

.region__name {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  min-height: var(--tap);
  padding: 0 10px 0 2px;
  text-align: left;
  background: none;
  border: 0;
  cursor: pointer;
}

.region__label {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.region__name--sido {
  font-size: 16px;
  font-weight: 750;
}

.region__name--sigungu {
  font-size: 15px;
  font-weight: 550;
}

.region__count {
  flex: none;
  min-width: 26px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface-3);
  border-radius: 999px;
}

/* 선택된 지역 강조 */
.region.is-active > .region__row {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.region.is-active > .region__row .region__name {
  color: var(--accent-text);
}

.region.is-active > .region__row .region__count {
  color: var(--on-strong);
  background: var(--accent);
}

/* 식당 항목: [이름 버튼][수정/삭제] */
.place {
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 2px 0;
  padding-right: 4px;
  border-radius: var(--radius-sm);
}

.place:hover {
  background: var(--surface-2);
}

.place__btn {
  flex: 1;
  min-width: 0;
  min-height: 52px;
  display: grid;
  grid-template-columns: 10px 1fr;
  column-gap: 10px;
  align-items: center;
  padding: 6px 8px;
  text-align: left;
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.place__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--surface);
}

.place__name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.place__meta {
  grid-column: 2;
  font-size: 13px;
  color: var(--text-muted);
}

.place__actions {
  flex: none;
  display: flex;
  opacity: 0.55;
  transition: opacity 0.15s;
}

.place:hover .place__actions,
.place.is-active .place__actions,
.place__actions:focus-within {
  opacity: 1;
}

.place.is-active {
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.place.is-active .place__name {
  font-weight: 750;
}

/* ===== 필터 바 ===== */
.filters {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 150;
}

.filters__row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.filters__label {
  flex: none;
  width: 32px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: var(--tap);
  padding: 0 15px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.chip:hover {
  background: var(--surface-2);
}

.chip.is-active {
  color: var(--on-strong);
  background: var(--strong);
  border-color: var(--strong);
}

.chip__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  box-shadow: 0 0 0 1.5px var(--surface);
}

.filters__reset {
  flex: none;
  margin-left: auto;
  min-height: var(--tap);
  padding: 0 12px;
  font-size: 14px;
  font-weight: 650;
  color: var(--danger);
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.filters__reset[hidden] {
  display: none;
}

.filters__reset:hover {
  background: var(--danger-soft);
}

/* ===== 결과 없음 ===== */
.empty-state {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 150;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 22px 24px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.empty-state[hidden] {
  display: none;
}

.empty-state__text {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 650;
}

.empty-state__reset {
  min-height: var(--tap);
  padding: 0 18px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.empty-state__reset:hover {
  background: var(--accent-hover);
}

/* ===== 식당 추가/수정 폼 (데스크톱: 왼쪽 패널 위에 열림) ===== */
.sheet {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--panel-width);
  max-width: 100%;
  height: auto;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  color: var(--text);
  background: var(--surface);
  border: 0;
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 600;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 16px 28px;
}

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

.form__title {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.form__close {
  width: var(--tap);
  height: var(--tap);
  font-size: 24px;
  line-height: 1;
  color: var(--text-muted);
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.form__close:hover {
  color: var(--text);
  background: var(--surface-2);
}

.form__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.form__label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

/* 입력창은 16px 이상 → iOS에서 자동 확대되지 않음 */
.form input,
.form select {
  width: 100%;
  min-width: 0;
  min-height: var(--tap);
  padding: 0 12px;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

.form input::placeholder {
  color: var(--text-muted);
  opacity: 0.8;
}

.form input:focus,
.form select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: transparent;
  background: var(--surface);
}

.form__row {
  display: flex;
  gap: 6px;
}

.form__row .tool-btn {
  flex: none;
}

.form__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form__location {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-muted);
  white-space: pre-line;
}

.form__location.is-ok {
  color: var(--ok-text);
}

.form__location.is-stale {
  color: var(--warn-text);
}

.form__error {
  margin: 0;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: var(--radius-sm);
}

.form__error[hidden] {
  display: none;
}

.form__error.is-info {
  color: var(--info-text);
  background: var(--info-soft);
}

.form__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.form__footer .tool-btn {
  min-width: 88px;
}

/* ===== 5) 지도 위 요소 ===== */

/* 핀 */
.pin {
  display: block;
  cursor: pointer;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
  transition: transform 0.15s;
  transform-origin: 50% 100%;
}

.pin:hover {
  transform: scale(1.15);
}

/* 폼의 미리보기 핀: 끌 수 있다는 표시로 살짝 통통 튐 */
.pin--preview {
  cursor: grab;
  animation: pin-bounce 1.2s ease-in-out infinite;
}

@keyframes pin-bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pin--preview {
    animation: none;
  }
}

/* 묶음 원 마커 */
.cluster {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  color: #fff;
  text-align: center;
  line-height: 1.15;
  border: 3px solid rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  transition: transform 0.15s;
}

.cluster:hover {
  transform: scale(1.08);
}

.cluster--sido {
  background: var(--cluster-sido);
}

.cluster--sigungu {
  background: var(--cluster-sigungu);
}

.cluster__name {
  max-width: 86%;
  overflow: hidden;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.cluster__count {
  font-size: 15px;
  font-weight: 800;
}

/* 범례 */
.legend {
  position: fixed;
  left: calc(var(--panel-width) + (100% - var(--panel-width)) / 2); /* 지도 영역의 가운데 */
  bottom: 36px; /* 네이버 로고·축척과 겹치지 않도록 */
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 14px;
  width: max-content; /* 고정 위치라도 left 때문에 좁아지지 않게 */
  max-width: calc(100% - var(--panel-width) - 32px);
  margin: 0;
  padding: 10px 16px;
  list-style: none;
  font-size: 13px;
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.legend[hidden] {
  display: none;
}

.legend__item {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.legend__dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--surface);
}

.legend__count {
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* 정보창 */
.info {
  min-width: 240px;
  max-width: 290px;
  padding: 16px 16px 10px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.info__name {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.info__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.info__tag {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: var(--tag-color, #6f6e77);
}

.info__tag--plain {
  color: var(--text);
  background: var(--surface-3);
}

.info__address {
  margin: 0 0 4px;
  color: var(--text-muted);
}

.info__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 -6px;
}

.info__actions {
  display: flex;
}

.info__link {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 6px;
  color: var(--accent-text);
  font-weight: 700;
  text-decoration: none;
  border-radius: var(--radius-sm);
}

.info__link:hover {
  text-decoration: underline;
}

/* 가벼운 알림 */
.toast {
  position: fixed;
  top: 132px; /* 필터 바 아래 */
  left: calc(var(--panel-width) + (100% - var(--panel-width)) / 2);
  transform: translateX(-50%);
  z-index: 500;
  width: max-content;
  max-width: calc(100% - var(--panel-width) - 32px);
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--on-strong);
  background: var(--strong);
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
}

.toast[hidden] {
  display: none;
}

/* 지도 로드 실패 안내 */
.map-error {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--bg);
  z-index: 1000;
}

.map-error[hidden] {
  display: none;
}

.map-error__box {
  max-width: 480px;
  width: 100%;
  padding: 28px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.map-error__title {
  margin: 0 0 8px;
  font-size: 21px;
  font-weight: 800;
  color: var(--danger);
}

.map-error__message {
  margin: 0 0 16px;
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.6;
}

.map-error__hints {
  margin: 0;
  padding-left: 18px;
  font-size: 14px;
  line-height: 1.8;
}

.map-error code {
  padding: 1px 6px;
  font-size: 13px;
  background: var(--surface-3);
  border-radius: 5px;
}

/* ===== 6) 반응형: 모바일 (600px 이하) =====
   위: 필터(가로 스크롤) / 가운데: 지도 / 아래: 끌어 올리는 목록 바텀시트 */
@media (max-width: 600px) {
  /* 지도: 화면 맨 위부터 바텀시트가 접힌 높이 직전까지 */
  .map-wrap {
    left: 0;
    bottom: var(--sheet-peek);
  }

  /* 필터 바: 종류·가격을 한 줄로 이어서 옆으로 스크롤 */
  .filters {
    flex-direction: row;
    gap: 14px;
    padding: 8px 12px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .filters::-webkit-scrollbar {
    display: none;
  }

  .filters__row {
    flex: none;
    gap: 8px;
  }

  .filters__row + .filters__row {
    padding-left: 14px;
    border-left: 1px solid var(--border);
  }

  .filters__label {
    width: auto;
  }

  .chips {
    flex-wrap: nowrap;
  }

  .filters__reset {
    margin-left: 4px;
  }

  /* 목록 패널 → 바텀시트 */
  .panel {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: auto;
    height: 88dvh;
    max-height: calc(100dvh - 72px);
    border-right: 0;
    border-top: 1px solid var(--border);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.14);
    z-index: 300;
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
    will-change: transform;
  }

  /* 펼침 정도: peek(접힘) / half(절반) / full(거의 전체) */
  .panel[data-sheet="peek"] {
    transform: translateY(calc(100% - var(--sheet-peek)));
  }

  .panel[data-sheet="half"] {
    transform: translateY(calc(100% - 50dvh));
  }

  .panel[data-sheet="full"] {
    transform: translateY(0);
  }

  .panel.is-dragging {
    transition: none;
  }

  .sheet-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 22px;
    margin: -12px -16px 2px;
    cursor: grab;
    touch-action: none;
  }

  .sheet-handle::before {
    content: "";
    width: 40px;
    height: 5px;
    background: var(--border-strong);
    border-radius: 999px;
  }

  .panel__header {
    padding: 12px 16px 12px;
    border-bottom: 1px solid var(--border);
    touch-action: none; /* 헤더를 끌어서 시트를 올리고 내림 */
  }

  .panel__title {
    margin-bottom: 10px;
    font-size: 17px;
  }

  .panel__tools {
    margin-bottom: 10px;
  }

  /* 범례: 바텀시트 바로 위, 한 줄 가로 스크롤 */
  .legend {
    left: 12px;
    right: 12px;
    bottom: calc(var(--sheet-peek) + 30px);
    transform: none;
    flex-wrap: nowrap;
    justify-content: flex-start;
    width: auto;
    max-width: none;
    padding: 8px 12px;
    overflow-x: auto;
    scrollbar-width: none;
    border-radius: 12px;
    font-size: 12px;
  }

  .legend::-webkit-scrollbar {
    display: none;
  }

  .toast {
    top: 72px;
    left: 50%;
    max-width: calc(100% - 32px);
  }

  /* 추가/수정 폼: 아래에서 올라오는 시트 (위쪽 지도에서 핀을 끌 수 있게 높이 제한) */
  .sheet {
    top: auto;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 62dvh;
    border-right: 0;
    border-top: 1px solid var(--border);
    border-radius: 20px 20px 0 0;
  }

  .form {
    gap: 14px;
    padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  }

  .info {
    min-width: 220px;
    max-width: min(290px, calc(100vw - 48px));
  }
}