:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #232936;
  --sub: #8a91a0;
  --line: #e8eaf0;
  --accent: #fb7185;
  --accent-deep: #f43f5e;
  --gold: #fbbf24;
  --u1: #3b82f6;   /* 준서 */
  --u2: #8b5cf6;   /* 민영 */
  --food: #ef4444;
  --cafe: #b08650;
  --activity: #14b8a6;
  --etc: #94a3b8;
  --ok: #22c55e;
  --radius: 16px;
  --header-h: 52px;
  --tabs-h: 44px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font: inherit; color: inherit; }

.icon {
  width: 1.05em; height: 1.05em;
  vertical-align: -0.18em; display: inline-block; flex-shrink: 0;
}
.logo-heart { color: var(--accent); }

/* ---------- 상단바 / 탭 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 18px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.me-chip {
  border-radius: 999px;
  padding: 3px 10px; font-size: 13px; font-weight: 700;
  background: var(--bg); color: var(--sub);
}
.me-chip.u1 { background: rgba(59, 130, 246, .12); color: var(--u1); }
.me-chip.u2 { background: rgba(139, 92, 246, .12); color: var(--u2); }

.who { font-weight: 700; }
.who.u1 { color: var(--u1); }
.who.u2 { color: var(--u2); }
.ghost-btn { color: var(--sub); font-size: 13px; }

.tabs {
  position: sticky; top: var(--header-h); z-index: 50;
  display: flex; height: var(--tabs-h);
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.tab {
  flex: 1; font-size: 15px; color: var(--sub); font-weight: 600;
  border-bottom: 2.5px solid transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }

main { max-width: 680px; margin: 0 auto; }

/* ---------- 지도 탭 ---------- */
#tab-map { position: relative; }
#map {
  width: 100%;
  height: calc(100dvh - var(--header-h) - var(--tabs-h));
  background: #ece7e2;
}
.map-fallback[hidden] { display: none; }
.map-fallback {
  height: 100%; display: flex; align-items: center; justify-content: center;
  text-align: center; color: var(--sub); padding: 24px; white-space: pre-line;
}

.search-wrap {
  position: absolute; top: 12px; left: 12px; right: 12px; z-index: 30;
}
.search-wrap input {
  width: 100%; height: 46px; padding: 0 16px;
  border: none; border-radius: 999px;
  background: var(--card);
  box-shadow: 0 4px 14px rgba(16, 24, 40, .14);
  outline: none;
}
.search-wrap input:focus { box-shadow: 0 4px 14px rgba(251, 113, 133, .3); }

.dropdown {
  margin-top: 8px; background: var(--card); border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(16, 24, 40, .18);
  overflow: hidden; max-height: 45dvh; overflow-y: auto;
}
.dropdown-item {
  display: block; width: 100%; text-align: left;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:active { background: var(--bg); }
.dropdown-item .di-title { font-weight: 600; }
.dropdown-item .di-sub { font-size: 12.5px; color: var(--sub); margin-top: 2px; }

/* 등록 장소 패널 (우상단, 접기/펴기) */
.place-panel {
  position: absolute; top: 70px; right: 12px; z-index: 25;
  display: flex; flex-direction: column; align-items: flex-end;
  max-width: min(82vw, 320px);
}
.panel-toggle {
  display: flex; align-items: center; gap: 6px;
  background: var(--card); border-radius: 999px;
  padding: 9px 14px; font-weight: 700; font-size: 13.5px;
  box-shadow: 0 4px 14px rgba(16, 24, 40, .16);
}
.panel-count {
  background: var(--accent); color: #fff;
  border-radius: 999px; padding: 1px 7px; font-size: 12px;
}
.panel-toggle .chev { transition: transform .18s; color: var(--sub); }
.panel-toggle.open .chev { transform: rotate(180deg); }
.panel-body {
  margin-top: 8px; width: min(82vw, 320px);
  background: var(--card); border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(16, 24, 40, .18);
  padding: 10px 12px;
  max-height: 46dvh; overflow-y: auto;
}
.panel-body .filter-row { margin: 2px 0 6px; }
.panel-body .chip { padding: 4px 10px; font-size: 12px; }
.panel-body .place-item { padding: 10px 2px; }
.pi-cat { color: var(--pin, var(--etc)); display: inline-flex; }

/* 마커 핀 */
.pin {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50% 50% 50% 6px;
  transform: rotate(-45deg);
  background: var(--pin, var(--etc));
  border: 2.5px solid #fff;
  box-shadow: 0 3px 8px rgba(16, 24, 40, .35);
}
.pin > span { transform: rotate(45deg); display: flex; color: #fff; }
.pin .icon { width: 16px; height: 16px; }
.pin-visited { opacity: .55; filter: saturate(.6); }

/* ---------- 바텀시트 ---------- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  max-width: 680px; margin: 0 auto;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 30px rgba(16, 24, 40, .22);
  max-height: 62dvh; overflow-y: auto;
  padding: 10px 18px calc(20px + env(safe-area-inset-bottom));
}
.sheet-grip {
  width: 42px; height: 4px; border-radius: 2px;
  background: var(--line); margin: 4px auto 12px;
}
.sheet h2 { font-size: 17px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sheet .meta { font-size: 13px; color: var(--sub); margin-top: 4px; }
.sheet-close {
  position: absolute; top: 12px; right: 14px;
  color: var(--sub); font-size: 18px; padding: 4px;
}

.cat-badge {
  font-size: 11.5px; font-weight: 700; color: #fff;
  border-radius: 999px; padding: 2px 9px;
  background: var(--pin, var(--etc));
}

.memo-box {
  margin-top: 12px; padding: 12px 14px;
  background: var(--bg); border-radius: 12px; font-size: 14px;
  white-space: pre-wrap;
}
.memo-box.empty { color: var(--sub); }

.review-box {
  margin-top: 10px; padding: 12px 14px;
  background: #fff7ed; border: 1px solid #ffe8cc;
  border-radius: 12px; font-size: 14px;
  white-space: pre-wrap;
}

.btn-row { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.btn {
  flex: 1; min-width: 100px;
  padding: 12px 10px; border-radius: 12px;
  font-weight: 700; font-size: 14px; text-align: center;
  background: var(--bg); color: var(--ink);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-danger { background: #fdecec; color: #d64545; flex: 0 1 auto; min-width: 72px; }
.btn-sub { background: var(--bg); color: var(--sub); }

/* 리스트 시트 */
.filter-row { display: flex; gap: 6px; margin: 10px 0; flex-wrap: wrap; }
.chip {
  border: 1.5px solid var(--line); border-radius: 999px;
  padding: 5px 12px; font-size: 13px; font-weight: 600; color: var(--sub);
  background: var(--card);
}
.chip.active { border-color: var(--ink); color: #fff; background: var(--ink); }

.place-item {
  display: block; width: 100%; text-align: left;
  padding: 12px 4px; border-bottom: 1px solid var(--line);
}
.place-item:last-child { border-bottom: none; }
.pi-top { display: flex; align-items: center; gap: 7px; }
.pi-name { font-weight: 700; }
.pi-check { color: var(--ok); font-size: 13px; font-weight: 700; }
.pi-sub { font-size: 12.5px; color: var(--sub); margin-top: 3px; }
.empty-note { text-align: center; color: var(--sub); padding: 28px 0; font-size: 14px; }

/* 등록 폼 */
.form-field { margin-top: 12px; }
.form-field label { display: block; font-size: 12.5px; color: var(--sub); font-weight: 700; margin-bottom: 6px; }
.form-field input, .form-field textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px;
  padding: 11px 13px; background: var(--card); outline: none; resize: none;
}
.form-field input:focus, .form-field textarea:focus { border-color: var(--accent); }

/* ---------- 땡기는 음식 탭 ---------- */
#tab-crave { padding: 14px 14px calc(28px + env(safe-area-inset-bottom)); }

.crave-form { display: flex; gap: 8px; }
.crave-form input {
  flex: 1; height: 48px; padding: 0 16px;
  border: none; border-radius: 999px; outline: none;
  background: var(--card);
  box-shadow: 0 3px 10px rgba(16, 24, 40, .1);
}
.crave-form input:focus { box-shadow: 0 3px 10px rgba(251, 113, 133, .28); }
.crave-form button {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 10px rgba(251, 113, 133, .35);
}
.crave-form button .icon { width: 22px; height: 22px; }

.crave-list { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }

.crave-card {
  background: var(--card); border-radius: var(--radius);
  padding: 13px 14px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 2px 8px rgba(16, 24, 40, .07);
}
.crave-main { flex: 1; min-width: 0; }
.crave-food { font-weight: 700; font-size: 15.5px; }
.crave-card .meta { font-size: 12.5px; color: var(--sub); margin-top: 3px; }
.crave-place {
  font-size: 12.5px; color: var(--activity); margin-top: 3px;
  display: inline-flex; align-items: center; gap: 3px;
  font-weight: 600; padding: 0;
}
.crave-place:active { opacity: .6; }

.flow-hint {
  font-size: 12px; color: var(--sub); line-height: 1.6;
  padding: 2px 6px 6px;
}
.flow-hint .icon { width: .95em; height: .95em; }

.badge {
  border-radius: 999px; padding: 7px 12px;
  font-size: 12.5px; font-weight: 700; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 4px;
}
.badge-craving { background: #ffe3e3; color: #e03131; }
.badge-going { background: #e7f0ff; color: #2f6fed; }
.badge-done { background: #e6f9e8; color: #2f9e44; }
.crave-x { color: var(--sub); padding: 6px; font-size: 15px; }

.archive { margin-top: 22px; }
.archive summary {
  font-weight: 700; color: var(--sub); cursor: pointer;
  padding: 8px 2px; user-select: none;
}
.archive .crave-card { opacity: .82; }
.badge-restore { background: var(--bg); color: var(--sub); font-size: 11.5px; padding: 5px 9px; }

/* ---------- 모달 / 토스트 ---------- */
#modal-root[hidden] { display: none; }
#modal-root {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(40, 30, 30, .45);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  width: 100%; max-width: 560px;
  background: var(--card); border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(24px + env(safe-area-inset-bottom));
  max-height: 72dvh; overflow-y: auto;
}
.modal h3 { font-size: 16.5px; margin-bottom: 6px; }
.modal .modal-sub { font-size: 13px; color: var(--sub); margin-bottom: 12px; }

.toast {
  position: fixed; bottom: calc(90px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  z-index: 200;
  background: var(--ink); color: #fff;
  border-radius: 999px; padding: 11px 20px;
  font-size: 14px; font-weight: 600; white-space: nowrap;
  box-shadow: 0 6px 18px rgba(16, 24, 40, .3);
}

/* ---------- 로그인 ---------- */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100dvh; padding: 20px;
}
.login-card {
  width: 100%; max-width: 360px;
  background: var(--card); border-radius: 24px;
  padding: 36px 28px;
  box-shadow: 0 10px 34px rgba(16, 24, 40, .12);
  text-align: center;
}
.login-card h1 { font-size: 24px; }
.login-sub { color: var(--sub); font-size: 13.5px; margin: 8px 0 24px; }
.login-card input {
  width: 100%; height: 48px; padding: 0 15px;
  border: 1.5px solid var(--line); border-radius: 12px;
  margin-bottom: 10px; outline: none; background: var(--bg);
}
.login-card input:focus { border-color: var(--accent); }
.login-card button {
  width: 100%; height: 48px; border-radius: 12px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 15.5px;
  margin-top: 6px;
}
.login-error { color: #d64545; font-size: 13.5px; margin-top: 12px; }
