/* ===== CSS 변수 ===== */
:root {
  --bg:       #FFFBF5;
  --bg2:      #FFF3E0;
  --bg3:      #FFE8C8;
  --text:     #2D1B00;
  --text2:    #9A7040;
  --border:   #E8D5B0;
  --accent:   #FF6B35;
  --cheer:    #FF6B35;
  --cheer-bg: #FFF0E8;
  --msg:      #7C3AED;
  --msg-bg:   #F3EEFF;
  --shadow:   0 2px 12px rgba(255,107,53,0.08);
  --radius:   16px;
}

[data-theme="dark"] {
  --bg:       #1A0D00;
  --bg2:      #251400;
  --bg3:      #331C00;
  --text:     #FFE8CC;
  --text2:    #C4922A;
  --border:   #3D2800;
  --cheer-bg: #2A1200;
  --msg-bg:   #1E1030;
  --shadow:   0 2px 12px rgba(0,0,0,0.3);
}

/* ===== 리셋 ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg2);
  color: var(--text);
  font-size: 14px;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ===== 로그인 ===== */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #FFF3E0 0%, #FFE0B2 50%, #FFCCBC 100%);
}

[data-theme="dark"] #login-screen {
  background: linear-gradient(160deg, #1A0D00 0%, #2A1400 50%, #331800 100%);
}

.login-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 40px rgba(255,107,53,0.15);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.login-logo {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.logo-icon { font-size: 48px; line-height: 1; }

.login-logo h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.5px;
}

.login-desc {
  text-align: center;
  font-size: 15px;
  color: var(--text2);
  line-height: 1.7;
}

.login-form { display: flex; flex-direction: column; gap: 10px; }

.login-hint {
  font-size: 11px;
  color: var(--text2);
  text-align: center;
  line-height: 1.5;
}

/* ===== 위치 권한 화면 ===== */
#location-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #FFF3E0 0%, #FFE0B2 50%, #FFCCBC 100%);
  padding: 20px;
}

[data-theme="dark"] #location-screen {
  background: linear-gradient(160deg, #1A0D00 0%, #2A1400 50%, #331800 100%);
}

.location-box {
  background: var(--bg);
  border-radius: 24px;
  padding: 32px 28px 28px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 12px 50px rgba(0,0,0,0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.loc-app-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}

.loc-app-icon { font-size: 22px; }

.loc-icon-wrap { margin: 4px 0; }

.loc-icon-bg {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FFF0E8, #FFD5C0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  box-shadow: 0 4px 16px rgba(255,107,53,0.2);
}

[data-theme="dark"] .loc-icon-bg {
  background: linear-gradient(135deg, #2A1200, #3D1A00);
}

.loc-title {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.5;
  color: var(--text);
}

.loc-reason {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.7;
}

.loc-list {
  list-style: none;
  width: 100%;
  background: var(--bg2);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.loc-list li {
  font-size: 13px;
  color: var(--text2);
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.4;
}

.loc-check {
  color: #22C55E;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.loc-lock { flex-shrink: 0; }

.loc-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  padding-top: 4px;
}

/* ===== 공통 입력/버튼 ===== */
input[type="text"], textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--bg2);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

input[type="text"]:focus, textarea:focus {
  border-color: var(--accent);
}

.btn-primary {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, #FF6B35, #FF4500);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  font-family: inherit;
}

.btn-primary:hover  { opacity: 0.92; }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  width: 100%;
  padding: 13px;
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.btn-secondary:hover { border-color: var(--text2); color: var(--text); }

/* ===== 앱 레이아웃 ===== */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
}

/* ===== 상단 네비 ===== */
.top-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 56px;
  max-width: 480px;
  margin: 0 auto;
  box-shadow: 0 1px 8px rgba(255,107,53,0.06);
}

.top-logo {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 20px;
}

.logo-text {
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.3px;
}

.top-actions { display: flex; align-items: center; gap: 4px; }

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  padding: 6px;
  border-radius: 8px;
  transition: background 0.15s;
  line-height: 1;
}

.icon-btn:hover { background: var(--bg2); }

.loc-status-btn {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text2);
  font-family: inherit;
}

.loc-status-btn:hover { border-color: var(--accent); color: var(--accent); }
.loc-status-btn.active { border-color: var(--accent); color: var(--accent); background: var(--cheer-bg); }

.text-btn {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.text-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ===== 메인 콘텐츠 ===== */
#content {
  padding-top: 56px;
  padding-bottom: 68px;
}

/* ===== 하단 네비 ===== */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 6px 0 8px;
  z-index: 100;
}

.nav-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 20px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--text2);
  transition: all 0.15s;
  font-family: inherit;
}

.nav-btn svg  { width: 22px; height: 22px; }
.nav-btn span { font-size: 10px; font-weight: 600; }
.nav-btn.active { color: var(--accent); }
.nav-btn:hover  { background: var(--bg2); color: var(--accent); }

.write-nav-btn {
  background: linear-gradient(135deg, #FF6B35, #FF4500);
  color: white !important;
  border-radius: 14px;
  padding: 6px 24px;
  box-shadow: 0 4px 12px rgba(255,107,53,0.35);
}

.write-nav-btn.active, .write-nav-btn:hover {
  color: white !important;
  background: linear-gradient(135deg, #FF4500, #E03A00);
}

/* ===== 반경 설정 바 ===== */
.radius-bar {
  margin: 12px 12px 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.radius-bar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

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

.radius-desc {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}

.radius-pills {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.radius-pills::-webkit-scrollbar { display: none; }

.radius-pill {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--bg2);
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.radius-pill:hover { border-color: var(--accent); color: var(--accent); }

.radius-pill.active {
  background: linear-gradient(135deg, #FF6B35, #FF4500);
  border-color: transparent;
  color: white;
  box-shadow: 0 2px 8px rgba(255,107,53,0.35);
}

/* ===== 위치 거부 안내 ===== */
.no-location-notice {
  margin: 12px 12px 0;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
}

.no-location-notice strong { display: block; margin-bottom: 3px; color: var(--text); }
.no-location-notice p { color: var(--text2); }

.inline-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  font-family: inherit;
}

.inline-btn:hover { text-decoration: underline; }

/* ===== 피드 공지 ===== */
.feed-notice {
  margin: 8px 12px 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text2);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ===== 포스트 카드 ===== */
.post-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 12px 12px 0;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.post-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 10px;
  flex-wrap: wrap;
}

.anon-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.anon-label { font-weight: 600; font-size: 14px; flex: 1; }

.post-distance {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
  background: var(--cheer-bg);
  border-radius: 20px;
  padding: 2px 8px;
}

.post-time {
  font-size: 11px;
  color: var(--text2);
}

.privacy-badge {
  font-size: 10px;
  color: var(--text2);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 8px;
  display: flex;
  align-items: center;
  gap: 3px;
}

.post-img {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
  display: block;
}

.post-caption {
  padding: 12px 14px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
}

.post-actions {
  display: flex;
  gap: 8px;
  padding: 4px 10px 10px;
  align-items: center;
}

/* ===== CHEER 버튼 ===== */
.cheer-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--cheer-bg);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  transition: all 0.2s;
  font-family: inherit;
}

.cheer-btn:hover {
  border-color: var(--cheer);
  color: var(--cheer);
}

.cheer-btn.cheered {
  background: linear-gradient(135deg, #FF6B35, #FF4500);
  border-color: transparent;
  color: white;
  box-shadow: 0 3px 10px rgba(255,107,53,0.4);
}

.cheer-btn .cheer-icon { font-size: 16px; line-height: 1; }

@keyframes cheerPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.25) rotate(-5deg); }
  70%  { transform: scale(0.95) rotate(3deg); }
  100% { transform: scale(1); }
}

.cheer-btn.pop .cheer-icon { animation: cheerPop 0.4s ease; }

/* ===== 응원 메시지 버튼 ===== */
.msg-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--msg-bg);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  transition: all 0.2s;
  font-family: inherit;
}

.msg-btn:hover { border-color: var(--msg); color: var(--msg); }

.post-bottom {
  padding: 0 14px 12px;
}

.view-msg-btn {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 0;
  font-family: inherit;
}

.view-msg-btn:hover { color: var(--msg); }

.msg-preview {
  padding: 2px 0;
  font-size: 13px;
  color: var(--text2);
  line-height: 1.5;
}

/* ===== 빈 상태 ===== */
.empty-state {
  text-align: center;
  padding: 80px 24px;
  color: var(--text2);
}

.empty-state .empty-icon { font-size: 56px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.empty-state p  { font-size: 14px; line-height: 1.8; }

/* ===== 글쓰기 ===== */
.create-wrap {
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.create-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.create-icon { font-size: 28px; margin-top: 2px; }
.create-header h2 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.create-header p  { font-size: 12px; color: var(--text2); line-height: 1.5; }

.upload-area {
  border: 2px dashed var(--border);
  border-radius: 12px;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text2);
  transition: border-color 0.2s;
  gap: 8px;
  padding: 20px;
}

.upload-area:hover { border-color: var(--accent); }
#upload-hint { font-size: 13px; }

#img-preview img {
  max-width: 100%;
  max-height: 280px;
  border-radius: 8px;
  object-fit: contain;
}

#caption {
  resize: vertical;
  min-height: 120px;
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.7;
  padding: 14px;
}

.anon-notice {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text2);
  background: var(--bg2);
  border-radius: 8px;
  padding: 8px 12px;
}

/* ===== 내 글 ===== */
.mine-header {
  display: flex;
  gap: 12px;
  padding: 20px 16px 0;
}

.cheer-summary {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 16px;
  text-align: center;
  box-shadow: var(--shadow);
}

.summary-num {
  font-size: 32px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 6px;
}

.summary-label {
  font-size: 12px;
  color: var(--text2);
  font-weight: 600;
}

.mine-tag {
  display: inline-block;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11px;
  color: var(--text2);
}

/* ===== 응원 메시지 모달 ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
}

.modal-bg {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
}

.modal-sheet {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  max-height: 75vh;
  display: flex;
  flex-direction: column;
}

.modal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 15px;
}

.modal-top button {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text2);
  padding: 4px;
  border-radius: 6px;
  transition: background 0.15s;
}

.modal-top button:hover { background: var(--bg2); }

#messages-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 18px;
}

.msg-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.msg-anon-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.msg-text {
  flex: 1;
  font-size: 14px;
  line-height: 1.5;
  padding-top: 4px;
}

.no-messages {
  text-align: center;
  color: var(--text2);
  padding: 32px 0;
  font-size: 14px;
  line-height: 2;
}

.message-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}

.message-bar input {
  flex: 1;
  border-radius: 20px;
  padding: 9px 14px;
  font-size: 14px;
}

#message-send {
  background: linear-gradient(135deg, #7C3AED, #5B21B6);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
  font-family: inherit;
}

#message-send:hover { opacity: 0.85; }

/* ===== 반응형 ===== */
@media (max-width: 480px) {
  .top-nav, .bottom-nav, .modal-sheet { max-width: 100%; }
  #app { max-width: 100%; }
}

/* ===== 로딩 상태 ===== */
.loading-state { text-align: center; padding: 48px 16px; color: #888; font-size: 14px; }

/* ===== 지도 ===== */
#map-view {
  position: relative;
  height: calc(100vh - 56px - 64px); /* 상단 네비 + 하단 네비 제외 */
  padding: 0;
}
#map-container {
  width: 100%;
  height: 100%;
  z-index: 0;
}
.map-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  color: #888;
  padding: 32px;
  text-align: center;
}
.map-empty .empty-icon { font-size: 48px; }
.map-empty h3 { font-size: 16px; color: #555; }
.map-empty p  { font-size: 14px; }

/* 지도 마커 */
.map-my-marker {
  font-size: 28px;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.3));
}
.map-post-marker {
  width: 40px;
  height: 40px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  border: 2px solid #fff;
}
.map-post-marker > span,
.map-post-marker {
  /* emoji inside rotated div - counter-rotate */
}
.map-post-marker.mine {
  border-color: #4f46e5;
  box-shadow: 0 2px 8px rgba(79,70,229,.4);
}

/* 지도 팝업 */
.map-popup { min-width: 160px; }
.map-popup-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
}
.map-popup-name { color: #333; }
.map-popup-caption {
  font-size: 13px;
  color: #444;
  margin-bottom: 8px;
  line-height: 1.5;
}
.map-popup-stats {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: #888;
}
