:root {
  --paper: #FBFAF6;
  --surface: #FFFFFF;
  --ink: #212A33;
  --muted: #66707A;
  --faint: #8A929B;
  --line: #E4E1D8;
  --divider: #EDEAE1;
  --sonar: #0E7C66;
  --sonar-soft: #E3F0EC;
  --seg-bg: #EFEDE4;
  --cat-situation: #C2502F;
  --cat-question: #2F6BC2;
  --cat-lost: #B07D18;
  --cat-news: #0E7C66;
  --cat-shop: #7A4FB0;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* hidden 속성이 .sheet/.panel의 display: flex에 지지 않도록 — 이 규칙이 없으면 모든 시트가 항상 표시됨 */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Noto Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
}
button { font-family: inherit; border: none; cursor: pointer; background: none; color: inherit; }
b { font-weight: 700; }
:focus-visible { outline: 2px solid var(--sonar); outline-offset: 2px; }

/* ---------- 상단 바 ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  background: var(--paper); border-bottom: 1px solid var(--divider);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.loc-row { display: flex; align-items: center; justify-content: space-between; }
.loc { display: flex; align-items: center; gap: 8px; min-width: 0; }
.loc b { font-family: 'IBM Plex Sans KR', sans-serif; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loc span { font-size: 12px; color: var(--muted); white-space: nowrap; }
.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink);
  font-size: 16px;
}
.radius-row { display: flex; align-items: center; gap: 8px; }
.radius-label { font-size: 12px; color: var(--muted); }
.seg { display: flex; background: var(--seg-bg); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { padding: 11px 16px; border-radius: 9px; font-size: 13px; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--sonar); font-weight: 700; box-shadow: 0 1px 3px rgba(30,40,50,.1); }

/* ---------- 지도 ---------- */
#map { position: fixed; inset: 0; z-index: 1; background: #F1EFE7; }
.leaflet-container { font: inherit; }
/* 외침 핀: 전파 아이콘이 든 말풍울 핀 + 통통 튀는 애니메이션 */
.pin-wrap { position: relative; width: 34px; height: 44px; cursor: pointer; }
.pin-shadow {
  position: absolute; left: 50%; bottom: 0; width: 16px; height: 5px; margin-left: -8px;
  border-radius: 50%; background: rgba(20,30,40,.28);
}
.pin-b { position: absolute; inset: 0; display: block; transform-origin: 50% 100%; filter: drop-shadow(0 2px 3px rgba(0,0,0,.25)); }
@media (prefers-reduced-motion: no-preference) {
  .pin-b { animation: pin-bounce 3s ease-in-out infinite; }
  .pin-shadow { animation: pin-shadow 3s ease-in-out infinite; }
}
@keyframes pin-bounce {
  0%, 32%, 100% { transform: translateY(0); }
  10% { transform: translateY(-10px); }
  20% { transform: translateY(0); }
  26% { transform: translateY(-4px); }
}
@keyframes pin-shadow {
  0%, 32%, 100% { transform: scaleX(1); opacity: .28; }
  10% { transform: scaleX(.62); opacity: .14; }
  20% { transform: scaleX(1); opacity: .28; }
}
.me-pin { width: 18px; height: 18px; border-radius: 50%; background: var(--sonar); border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(14,124,102,.18); }

/* ---------- 하단 UI 스택 (버튼 줄 + 미리보기 카드, 겹침 없음) ---------- */
#bottom-ui {
  position: fixed; z-index: 1000; left: 12px; right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.bottom-actions { display: flex; align-items: flex-end; justify-content: space-between; }
.bottom-actions > button { pointer-events: auto; }
.float-btn {
  display: flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink);
  box-shadow: 0 2px 8px rgba(30,40,50,.12);
}
.fab {
  display: flex; align-items: center; gap: 8px; height: 54px; padding: 0 20px;
  border-radius: 27px; background: var(--sonar); color: #fff;
  font-family: 'IBM Plex Sans KR', sans-serif; font-size: 15px; font-weight: 600;
  box-shadow: 0 4px 14px rgba(14,124,102,.35);
}

/* ---------- 미리보기 카드 ---------- */
.preview {
  pointer-events: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 12px 16px; box-shadow: 0 4px 16px rgba(30,40,50,.1);
  display: flex; flex-direction: column; gap: 6px; cursor: pointer;
}
.preview .card-text {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- 공통 카드 요소 ---------- */
.chip { font-size: 11px; font-weight: 700; border-radius: 5px; padding: 2px 8px; }
.chip.상황 { color: var(--cat-situation); background: #F7E8E2; }
.chip.질문 { color: var(--cat-question); background: #E5EDF8; }
.chip.분실 { color: var(--cat-lost); background: #F6EEDC; }
.chip.소식 { color: var(--cat-news); background: #E3F0EC; }
.chip.가게 { color: #fff; background: var(--cat-shop); }
.chip.official { color: #fff; background: var(--sonar); }
.meta { font-size: 12px; color: var(--muted); }
.card-text { font-size: 14px; line-height: 1.55; word-break: break-word; }
.card-foot { display: flex; align-items: center; gap: 14px; font-size: 12px; color: var(--muted); }
.echo-ic { color: var(--sonar); }

/* ---------- 패널 / 시트 ---------- */
.panel, .sheet {
  position: fixed; inset: 0; z-index: 2000; background: var(--paper);
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--divider);
}
.panel-head b { font-family: 'IBM Plex Sans KR', sans-serif; font-size: 17px; }
.sort-row { display: flex; gap: 8px; padding: 12px 16px 4px; }
.sort-row button {
  padding: 12px 18px; border-radius: 22px; font-size: 13px;
  color: var(--muted); background: var(--surface); border: 1px solid var(--line);
}
.sort-row button.on { color: #fff; background: var(--sonar); border-color: var(--sonar); font-weight: 700; }
.list-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 12px 16px calc(24px + env(safe-area-inset-bottom)); }
.list-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; cursor: pointer;
}
.list-card.shop { border: 1.5px solid var(--cat-shop); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-head .left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.life { font-size: 11px; color: var(--faint); white-space: nowrap; }
.empty { text-align: center; color: var(--muted); font-size: 14px; padding: 48px 20px; line-height: 1.7; }

/* ---------- 작성 ---------- */
.sheet { gap: 14px; }
.loc-banner {
  margin: 4px 16px 0; display: flex; align-items: center; gap: 10px;
  background: var(--sonar-soft); border-radius: 12px; padding: 12px 14px;
}
.loc-banner div { display: flex; flex-direction: column; }
.loc-banner b { font-size: 13px; color: var(--sonar); }
.loc-banner span { font-size: 11.5px; color: var(--muted); }
.cat-label { font-size: 13px; font-weight: 700; color: var(--muted); padding: 0 16px; }
.cat-row { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 16px; }
.cat-row button {
  padding: 13px 17px; border-radius: 22px; font-size: 13px;
  color: var(--muted); background: var(--surface); border: 1px solid var(--line);
}
.cat-row button.on { color: #fff; font-weight: 700; border-color: transparent; }
.cat-row button[data-c="상황"].on { background: var(--cat-situation); }
.cat-row button[data-c="질문"].on { background: var(--cat-question); }
.cat-row button[data-c="분실"].on { background: var(--cat-lost); }
.cat-row button[data-c="소식"].on { background: var(--cat-news); }
.cat-row button[data-c="가게"].on { background: var(--cat-shop); }
.textbox { margin: 0 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; }
.textbox textarea {
  width: 100%; border: none; resize: none; background: none;
  /* 16px 미만이면 iOS가 포커스 시 화면을 자동 확대함 */
  font: 16px/1.6 'Noto Sans KR', sans-serif; color: var(--ink); outline: none;
}
.counter { text-align: right; font-size: 12px; color: var(--faint); }
.rule-note { margin: 0 16px; background: #F3F1EA; border-radius: 12px; padding: 12px 14px; font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.photo-row { display: flex; align-items: center; gap: 12px; padding: 0 16px; }
.photo-btn {
  display: flex; align-items: center; gap: 8px; padding: 14px 18px;
  border: 1.5px dashed #C9C5B8; border-radius: 12px; color: var(--muted); font-size: 13px;
}
.photo-preview { position: relative; }
.photo-preview img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); display: block; }
.photo-preview button {
  position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; border-radius: 12px;
  background: var(--ink); color: #fff; font-size: 12px; display: flex; align-items: center; justify-content: center;
}
.card-img { width: 100%; max-height: 180px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.detail-img { width: 100%; border-radius: 12px; border: 1px solid var(--line); }
#btn-alert.on, #btn-account.on { color: #fff; background: var(--sonar); border-color: var(--sonar); }
.legal-links { text-align: center; font-size: 12px; color: var(--faint); padding: 8px 0 4px; }
.legal-links a { color: var(--muted); }
.fineprint a { color: var(--sonar); }
.btn-primary {
  margin: auto 16px calc(24px + env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 54px; border-radius: 14px; background: var(--sonar); color: #fff;
  font-family: 'IBM Plex Sans KR', sans-serif; font-size: 16px; font-weight: 600;
  flex-shrink: 0;
}
.btn-primary:disabled { opacity: .4; cursor: default; }

/* ---------- 상세 ---------- */
#detail-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; padding: 18px 20px; }
.detail-text { font-size: 16px; line-height: 1.65; word-break: break-word; }
.detail-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.life-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.life-card .row { display: flex; justify-content: space-between; font-size: 12px; }
.life-card .row b { color: var(--sonar); }
.bar { height: 6px; background: var(--seg-bg); border-radius: 3px; overflow: hidden; }
.bar > div { height: 100%; background: var(--sonar); border-radius: 3px; }
.act-row { display: flex; gap: 10px; }
.act-row button {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 50px; border-radius: 13px;
  font-family: 'IBM Plex Sans KR', sans-serif; font-size: 15px; font-weight: 600;
}
.btn-echo { background: var(--sonar); color: #fff; }
.btn-echo.done { background: var(--sonar-soft); color: var(--sonar); }
.reply-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 5px; }
.reply-card .who { display: flex; gap: 8px; align-items: center; font-size: 12.5px; }
.reply-card .who b { font-weight: 700; }
.reply-card .who span { font-size: 11.5px; color: var(--faint); }
.reply-card .txt { font-size: 13.5px; line-height: 1.55; }
.reply-box {
  border-top: 1px solid var(--divider); background: var(--paper);
  padding: 10px 16px calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 6px;
}
.reply-hint { font-size: 11.5px; color: var(--sonar); padding-left: 6px; }
.reply-row { display: flex; align-items: center; gap: 10px; }
.reply-row input {
  flex: 1; height: 46px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 23px; padding: 0 18px; font: 16px 'Noto Sans KR', sans-serif; color: var(--ink); outline: none;
}
.send-btn { display: flex; align-items: center; justify-content: center; width: 46px; height: 46px; border-radius: 23px; background: var(--sonar); flex-shrink: 0; }

/* ---------- 마이페이지 ---------- */
.mypage-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; padding: 18px 16px; }
.profile-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.nick-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.nick { font-family: 'IBM Plex Sans KR', sans-serif; font-size: 20px; font-weight: 700; }
.nick-hint { margin: 0; font-size: 12px; color: var(--faint); line-height: 1.6; }
#nick-input {
  flex: 1; height: 46px; background: var(--paper); border: 1px solid var(--line);
  border-radius: 12px; padding: 0 14px; font: 16px 'Noto Sans KR', sans-serif; color: var(--ink); outline: none;
}
.nick-save { height: 46px; padding: 0 18px; border-radius: 12px; background: var(--sonar); color: #fff; font-weight: 700; font-size: 14px; }
.my-shouts-head { display: flex; align-items: center; gap: 8px; padding: 0 2px; }
.my-shouts-head b { font-family: 'IBM Plex Sans KR', sans-serif; font-size: 16px; }
.my-shouts { display: flex; flex-direction: column; gap: 10px; }
.mypage-foot { padding: 12px 16px calc(20px + env(safe-area-inset-bottom)); border-top: 1px solid var(--divider); }
.btn-logout {
  width: 100%; height: 50px; border-radius: 13px; background: var(--surface);
  border: 1px solid var(--line); color: var(--cat-situation); font-size: 15px; font-weight: 700;
}

/* ---------- 온보딩 ---------- */
.overlay { position: fixed; inset: 0; z-index: 3000; background: var(--paper); overflow-y: auto; }
.onboard-inner {
  min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 20px; padding: 48px 28px; text-align: center;
}
.onboard-inner h1 { font-family: 'IBM Plex Sans KR', sans-serif; font-size: 34px; margin: 0; letter-spacing: -0.02em; }
.tagline { font-size: 15px; color: var(--muted); line-height: 1.6; margin: 0; }
.principles { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 360px; }
.pcard {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; text-align: left; display: flex; flex-direction: column; gap: 2px;
}
.pcard b { font-size: 14px; }
.pcard span { font-size: 12.5px; color: var(--muted); }
.onboard-inner .btn-primary { margin: 8px 0 0; width: 100%; max-width: 360px; }
.fineprint { font-size: 12px; color: var(--faint); line-height: 1.6; margin: 0; }

/* ---------- 토스트 ---------- */
#toast {
  position: fixed; z-index: 4000; left: 50%; transform: translateX(-50%);
  bottom: calc(170px + env(safe-area-inset-bottom));
  background: var(--ink); color: #fff; font-size: 13.5px;
  padding: 11px 20px; border-radius: 22px; box-shadow: 0 4px 14px rgba(0,0,0,.25);
  max-width: 86vw; text-align: center;
}

@media (min-width: 700px) {
  #topbar, #bottom-ui { max-width: 480px; left: 50%; transform: translateX(-50%); right: auto; width: 100%; }
  .panel, .sheet { max-width: 480px; left: 50%; transform: translateX(-50%); }
}
