/* ===== sojutrip — 귀여운 네오브루탈리즘 ===== */

:root {
  --ink: #1d1d1f;
  --paper: #FFF9F0;
  --pink: #FFD6E8;
  --pink-deep: #FFB3D1;
  --mint: #C9F2C7;
  --yellow: #FFF3B0;
  --blue: #BFD7FF;
  --lilac: #E3D0FF;
  --border: 3px solid var(--ink);
  --shadow: 4px 4px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --radius: 14px;
  --font-head: 'Jua', 'Apple SD Gothic Neo', sans-serif;
  --font-body: 'Gowun Dodum', 'Apple SD Gothic Neo', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- 상단 바 ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--pink);
  border-bottom: var(--border);
  flex-wrap: wrap;
  z-index: 1200;
  position: relative;
}

.logo { display: flex; align-items: center; gap: 8px; }

.logo-emoji {
  font-size: 30px;
  background: #fff;
  border: var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  padding: 2px 7px;
  transform: rotate(-4deg);
}

.logo-text h1 {
  font-family: var(--font-head);
  font-size: 24px;
  line-height: 1;
  letter-spacing: -0.5px;
}

.logo-text p { font-size: 12px; color: #444; }

.search {
  position: relative;
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 180px;
  max-width: 460px;
}

.search input {
  flex: 1;
  font-family: var(--font-body);
  font-size: 16px;
  padding: 9px 14px;
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  background: #fff;
  outline: none;
  min-width: 0;
}

.search input:focus { background: var(--yellow); }

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: #fff;
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 300px;
  overflow-y: auto;
  z-index: 1300;
}

.search-results h4 {
  font-family: var(--font-head);
  font-size: 13px;
  padding: 8px 12px 4px;
  background: var(--lilac);
  border-bottom: 2px solid var(--ink);
}

.search-results button {
  display: block;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  padding: 12px;
  border: none;
  border-bottom: 2px dashed #ddd;
  background: none;
  cursor: pointer;
}

.search-results button:hover { background: var(--yellow); }

.search-results .no-result { padding: 12px; font-size: 14px; text-align: center; }

/* ---------- 버튼 ---------- */
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  font-family: var(--font-head);
  font-size: 16px;
  padding: 10px 15px;
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  user-select: none;
  transition: transform .08s, box-shadow .08s;
  display: inline-block;
  background: #fff;
  color: var(--ink);
}

.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }

.btn-pink   { background: var(--pink-deep); }
.btn-blue   { background: var(--blue); }
.btn-mint   { background: var(--mint); }
.btn-yellow { background: var(--yellow); }

/* ---------- 레이아웃 ---------- */
.layout {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
}

.map-wrap { flex: 1; position: relative; min-width: 0; }

#map { position: absolute; inset: 0; background: var(--blue); }

/* 플로팅 버튼 */
.fabs {
  position: absolute;
  right: 14px;
  bottom: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
}

.fab {
  width: 52px;
  height: 52px;
  font-size: 22px;
  border: var(--border);
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .08s, box-shadow .08s;
}

.fab:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }

/* ---------- 재생 바 ---------- */
.playbar {
  position: absolute;
  left: 14px;
  bottom: 22px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: #fff;
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 12px;
  max-width: min(560px, calc(100% - 100px));
}

.play-btn { font-size: 18px; padding: 8px 16px; }

.play-date { display: flex; align-items: center; gap: 6px; }

.play-date input[type="date"] {
  font-family: var(--font-body);
  font-size: 15px;
  padding: 7px 8px;
  border: 2.5px solid var(--ink);
  border-radius: 10px;
  background: var(--yellow);
  color: var(--ink);
}

.mini-btn {
  font-family: var(--font-head);
  font-size: 14px;
  min-width: 38px;
  min-height: 38px;
  border: 2.5px solid var(--ink);
  border-radius: 10px;
  background: var(--blue);
  box-shadow: 2px 2px 0 var(--ink);
  cursor: pointer;
}

.mini-btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }

#playSlider {
  flex: 1;
  min-width: 120px;
  accent-color: #FF7BAC;
  height: 22px;
}

.play-clock {
  font-family: var(--font-head);
  font-size: 16px;
  background: var(--mint);
  border: 2.5px solid var(--ink);
  border-radius: 10px;
  padding: 5px 10px;
  min-width: 64px;
  text-align: center;
}

/* 걷는 캐릭터 */
.walker {
  width: 46px;
  height: 46px;
  background: #fff;
  border: var(--border);
  border-radius: 50% 50% 50% 12px;
  box-shadow: 3px 3px 0 var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  animation: waddle .5s ease-in-out infinite;
}

.walker .face { display: inline-block; }

.walker .face.flip { transform: scaleX(-1); }

@keyframes waddle {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50%      { transform: translateY(-6px) rotate(5deg); }
}

.photo-marker.pop { animation: pop .7s ease; }

@keyframes pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.35) rotate(-4deg); }
  100% { transform: scale(1); }
}

/* 드래그 앤 드롭 힌트 */
.drop-hint {
  position: absolute;
  inset: 0;
  z-index: 1100;
  background: rgba(255, 214, 232, .6);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.drop-card {
  font-family: var(--font-head);
  font-size: 22px;
  background: #fff;
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 34px;
  transform: rotate(-2deg);
}

/* ---------- 사이드 패널 ---------- */
.panel {
  width: 360px;
  background: var(--paper);
  border-left: var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 1000;
}

.panel-handle { display: none; }

.panel-head {
  padding: 14px 14px 8px;
  position: sticky;
  top: 0;
  background: var(--paper);
  z-index: 5;
}

.panel-head h2 {
  font-family: var(--font-head);
  font-size: 21px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.clear-btn {
  font-family: var(--font-head);
  font-size: 12px;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 9px;
  box-shadow: 2px 2px 0 var(--ink);
  padding: 4px 8px;
  cursor: pointer;
}

.clear-btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }

.stats {
  margin-top: 6px;
  font-size: 13.5px;
  background: var(--mint);
  border: 2px solid var(--ink);
  border-radius: 10px;
  box-shadow: 2px 2px 0 var(--ink);
  padding: 6px 10px;
  display: inline-block;
}

/* 빈 상태 안내 */
.empty { padding: 10px 14px 20px; }

.empty-card {
  background: #fff;
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 14px;
  text-align: center;
  font-size: 14.5px;
  line-height: 1.8;
  display: grid;
  gap: 10px;
}

.empty-emoji { font-size: 34px; }

.empty-tip {
  background: var(--yellow);
  border: 2px dashed var(--ink);
  border-radius: 10px;
  padding: 6px;
}

.empty-privacy { font-size: 12.5px; color: #555; }

/* 갤러리 — 날짜별 큰 카테고리 */
.gallery {
  display: grid;
  gap: 14px;
  padding: 6px 14px 16px;
}

#nogpsGallery {
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 12px;
}

.day-group {
  background: #fff;
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 12px;
}

.day-title {
  font-family: var(--font-head);
  font-size: 17px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.day-num {
  font-size: 12px;
  background: var(--lilac);
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 1px 6px;
}

.day-count {
  font-size: 12px;
  background: var(--yellow);
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 1px 6px;
}

.day-play {
  font-family: var(--font-head);
  font-size: 12.5px;
  margin-left: auto;
  background: var(--mint);
  border: 2px solid var(--ink);
  border-radius: 9px;
  box-shadow: 2px 2px 0 var(--ink);
  padding: 4px 8px;
  cursor: pointer;
}

.day-play:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }

.day-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 12px;
}

.thumb {
  position: relative;
  border: var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  aspect-ratio: 1;
  cursor: pointer;
  background: #fff;
  padding: 0;
  transition: transform .08s, box-shadow .08s;
}

.thumb:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }

.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; image-rendering: pixelated; }

.thumb .badge {
  position: absolute;
  top: 4px;
  left: 4px;
  font-size: 12px;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 1px 5px;
}

.thumb .date {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  font-size: 11.5px;
  background: rgba(255,255,255,.95);
  border-top: 2px solid var(--ink);
  padding: 2px 4px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thumb.highlight { outline: 4px solid var(--pink-deep); }

/* 위치 없는 사진 */
.nogps { border-top: 3px dashed var(--ink); margin-top: 8px; padding-top: 10px; }

.nogps h3 { font-family: var(--font-head); font-size: 15px; padding: 0 14px; }

.nogps-tip { font-size: 13px; color: #555; padding: 4px 14px 8px; line-height: 1.6; }

/* ---------- 지도 마커 / 팝업 ---------- */
.photo-marker {
  border: var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  background: #fff;
  width: 52px !important;
  height: 52px !important;
}

.photo-marker img { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }

.photo-marker.estimated { border-style: dashed; }

.visit-marker {
  width: 18px !important;
  height: 18px !important;
  background: var(--pink-deep);
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  box-shadow: 2px 2px 0 var(--ink);
}

.search-pin {
  font-size: 30px;
  width: 34px !important;
  height: 34px !important;
  text-align: center;
  filter: drop-shadow(2px 2px 0 var(--ink));
}

.leaflet-popup-content-wrapper {
  border: var(--border);
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow);
  font-family: var(--font-body);
}

.leaflet-popup-tip { border: 2px solid var(--ink); }

.popup-photo img {
  width: 100%;
  max-width: 220px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  display: block;
  image-rendering: pixelated; /* 원본 로드 전 픽셀 썸네일 표시 */
}

.popup-photo img.orig { image-rendering: auto; }

.popup-photo .cap { font-size: 13.5px; margin-top: 8px; line-height: 1.6; }

.popup-photo .tag {
  font-family: var(--font-head);
  font-size: 11px;
  background: var(--lilac);
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 1px 6px;
  display: inline-block;
  margin-top: 4px;
}

/* 추천 스팟 (제휴 콘텐츠 — 앱 콘텐츠와 같은 결로, 배지로만 구분) */
.spot-marker {
  width: 34px !important;
  height: 34px !important;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  box-shadow: 2px 2px 0 var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  opacity: .95;
}

.popup-spot b { font-family: var(--font-head); font-size: 15px; }

.popup-spot p { font-size: 13px; line-height: 1.6; margin: 6px 0 8px; }

.spot-link {
  display: inline-block;
  font-family: var(--font-head);
  font-size: 13px;
  color: var(--ink);
  background: var(--yellow);
  border: 2px solid var(--ink);
  border-radius: 9px;
  box-shadow: 2px 2px 0 var(--ink);
  padding: 5px 10px;
  text-decoration: none;
}

.spot-link:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }

.spot-disclosure {
  display: block;
  font-size: 10.5px;
  color: #666;
  margin-top: 7px;
}

/* 광고 슬롯 (비어 있으면 숨김 — 애드센스/애드몹 코드가 들어오면 노출) */
.ad-slot {
  flex: none;
  background: #fff;
  border-top: var(--border);
  padding: 4px;
  text-align: center;
  min-height: 54px;
}

.ad-slot:empty { display: none; }

/* 지도 기본 컨트롤도 브루탈리즘으로 */
.leaflet-control-zoom a {
  border: 2.5px solid var(--ink) !important;
  background: var(--yellow) !important;
  color: var(--ink) !important;
  font-weight: bold;
}

.leaflet-control-zoom { border: none !important; box-shadow: var(--shadow-sm) !important; border-radius: 10px; overflow: hidden; }

.leaflet-control-attribution { font-size: 9px; }

/* ---------- 시네마 모드 (재생 시 UI 최소화) ---------- */
.topbar, .panel {
  transition: transform .22s ease, opacity .22s ease;
  will-change: transform;
}

body.cinema .topbar { transform: translateY(-115%) scale(.96); opacity: 0; pointer-events: none; }
body.cinema .panel  { transform: translateX(112%) scale(.96); opacity: 0; pointer-events: none; }
body.cinema-gone .topbar, body.cinema-gone .panel { display: none; }

/* 최소화 독 아이콘 */
.dock {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 1500;
  display: flex;
  gap: 8px;
}

.dock-btn {
  width: 46px;
  height: 46px;
  font-size: 21px;
  background: #fff;
  border: var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  animation: dock-pop .25s ease;
  transition: transform .08s, box-shadow .08s;
}

.dock-btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }

@keyframes dock-pop {
  from { transform: translateY(-16px) scale(.7); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

/* ---------- 원본 보기 라이트박스 ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 2500;
  background: rgba(29, 29, 31, .82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.lightbox-card {
  background: var(--paper);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: 6px 6px 0 #000;
  padding: 12px;
  max-width: 94vw;
  animation: dock-pop .2s ease;
}

.lightbox-card img {
  display: block;
  max-width: 90vw;
  max-height: 68vh;
  border: 2.5px solid var(--ink);
  border-radius: 10px;
  image-rendering: auto;
}

.lightbox-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* 팝업 하단 버튼 */
.popup-actions { display: flex; gap: 8px; margin-top: 8px; }

.popup-actions .mini-btn { font-size: 12.5px; padding: 5px 9px; min-height: 34px; min-width: auto; }

/* ---------- 토스트 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  font-family: var(--font-head);
  font-size: 14.5px;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 3px solid #fff;
  box-shadow: var(--shadow);
  z-index: 3000;
  max-width: 86vw;
  text-align: center;
}

/* ---------- 모바일 ---------- */
@media (max-width: 767px) {
  .topbar { padding: 8px 10px; gap: 8px; }
  .logo-text p { display: none; }
  .logo-text h1 { font-size: 20px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .actions { margin-left: auto; }
  .btn { font-size: 15px; padding: 9px 12px; }

  .layout { flex-direction: column; }

  .panel {
    width: 100%;
    border-left: none;
    border-top: var(--border);
    height: 42vh;
    flex: none;
    transition: height .25s ease;
  }

  .panel.collapsed { height: 46px; overflow: hidden; }

  .panel-handle {
    display: block;
    width: 100%;
    background: var(--lilac);
    border: none;
    border-bottom: 2px solid var(--ink);
    padding: 10px 0;
    cursor: pointer;
    flex: none;
  }

  .handle-bar {
    display: block;
    width: 52px;
    height: 7px;
    background: var(--ink);
    border-radius: 4px;
    margin: 0 auto;
  }

  .fabs { bottom: 88px; }

  body.cinema .panel { transform: translateY(112%) scale(.96); }

  .playbar {
    left: 8px;
    right: 8px;
    bottom: 8px;
    max-width: none;
    padding: 8px 10px;
    gap: 8px;
  }

  .play-date input[type="date"] { font-size: 16px; }

  .play-clock { font-size: 15px; }
  .day-grid, #nogpsGallery { grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 10px; }
}
