/* 우리 추억 지도 v2 — warm couple theme, 색칠 타일 지도 */
:root {
  --bg: #fff7f4;
  --card: #ffffff;
  --ink: #3d2c33;
  --sub: #9b8a90;
  --brand: #ff5c74;
  --brand-dark: #e84a63;
  --brand-soft: #ffe3e8;
  --line: #f3e0dc;
  --danger: #d64550;
  --shadow: 0 6px 24px rgba(61, 44, 51, .14);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
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); overscroll-behavior: none;
}
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, textarea {
  font: inherit; color: var(--ink); width: 100%;
  border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fff;
}
input:focus, textarea:focus { outline: none; border-color: var(--brand); }
[hidden] { display: none !important; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 14px; padding: 12px 18px; font-weight: 700;
  background: #fff; border: 1.5px solid var(--line); color: var(--ink);
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:active { background: var(--brand-dark); }
.btn.ghost { background: #fff; }
.btn.danger { color: var(--danger); border-color: #f2c6c9; }
.btn.small { padding: 8px 14px; border-radius: 10px; font-size: 14px; }
.btn.big { width: 100%; padding: 15px; font-size: 17px; }
.btn.wide { width: 100%; margin-top: 4px; }
.btn.link { border: 0; color: var(--sub); font-weight: 500; }

/* ---------- setup ---------- */
.screen {
  min-height: 100%; display: flex; align-items: center; justify-content: center;
  padding: calc(24px + var(--sat)) 20px calc(24px + var(--sab));
}
.setup-card { width: 100%; max-width: 380px; text-align: center; }
.logo { width: 84px; height: 84px; border-radius: 24px; box-shadow: var(--shadow); margin-bottom: 14px; }
.setup-card h1 { font-size: 26px; margin-bottom: 6px; }
.tagline { color: var(--sub); margin-bottom: 26px; }
#setupHome .btn, #setupCreate .btn, #setupJoin .btn { margin-bottom: 10px; }
.hint { color: var(--sub); font-size: 14px; line-height: 1.5; margin-bottom: 12px; }
.code-box {
  background: var(--brand-soft); border: 1.5px dashed var(--brand); border-radius: 14px;
  padding: 14px 10px; font-weight: 800; letter-spacing: .5px; font-size: 15px;
  word-break: break-all; margin-bottom: 10px; user-select: all;
}
.code-box.small { font-size: 13px; padding: 10px; }
.field { display: block; text-align: left; margin: 12px 0; }
.field > span { display: block; font-size: 13px; font-weight: 700; color: var(--sub); margin-bottom: 6px; }
.fineprint { font-size: 12px; color: var(--sub); line-height: 1.6; margin-top: 18px; }

/* ---------- app frame ---------- */
#app { position: fixed; inset: 0; display: flex; flex-direction: column; }
main { flex: 1; position: relative; min-height: 0; }
.view { position: absolute; inset: 0; }
.view.scroll { overflow-y: auto; padding: calc(16px + var(--sat)) 16px 24px; }
#tabbar {
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: var(--sab);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 0 7px; font-size: 20px; color: var(--sub); filter: grayscale(1); opacity: .55;
}
.tab span { font-size: 11px; font-weight: 700; }
.tab.active { color: var(--brand); filter: none; opacity: 1; }

/* ---------- 색칠 지도 (시·군 경계) ---------- */
.map-view {
  display: flex; flex-direction: column;
  padding: calc(12px + var(--sat)) 12px calc(10px + 2px);
}
.map-head { margin-bottom: 8px; }
.map-head h2 { font-size: 20px; }
#koreaMap {
  flex: 1; min-height: 0;
  touch-action: none; /* 지도 위 제스처는 팬·핀치로 사용 */
}
#koreaMap svg { width: 100%; height: 100%; display: block; }
.rg { cursor: pointer; }
.rg:focus-visible { outline: none; }
.rg-path {
  stroke: #4a4a4a; stroke-width: .35; stroke-linejoin: round;
  transition: filter .12s ease;
}
.rg:active .rg-path, .rg:focus-visible .rg-path { filter: brightness(.93); }
.prov-line {
  fill: none; stroke: #1f1f1f; stroke-width: 1.1; stroke-linejoin: round;
  pointer-events: none;
}
.rg-name {
  font-weight: 700; fill: var(--ink);
  text-anchor: middle; paint-order: stroke; stroke: rgba(255,255,255,.8); stroke-width: 1.6px;
  pointer-events: none;
}
.rg-cnt {
  font-weight: 800; fill: var(--brand-dark);
  text-anchor: middle; paint-order: stroke; stroke: rgba(255,255,255,.8); stroke-width: 1.4px;
  pointer-events: none;
}
.inset-frame { fill: none; stroke: #b3a19d; stroke-width: .8; stroke-dasharray: 3 2.2; }
.inset-caption { font-size: 6.5px; font-weight: 700; fill: var(--sub); text-anchor: middle; }
.inset-hit { fill: transparent; cursor: pointer; }
.inset-hit:focus-visible { outline: none; stroke: var(--ink); stroke-width: 1.5; }
.map-reset {
  position: absolute; right: 14px; bottom: 44px; box-shadow: var(--shadow); z-index: 10;
}
.map-hint { text-align: center; color: var(--sub); font-size: 11.5px; margin-top: 6px; }
.map-hint { text-align: center; color: var(--sub); font-size: 12.5px; margin-top: 12px; }
.sync-badge {
  position: fixed; top: calc(12px + var(--sat)); left: 50%; transform: translateX(-50%);
  z-index: 550; background: rgba(61,44,51,.85); color: #fff; font-size: 12px; font-weight: 600;
  padding: 6px 12px; border-radius: 999px; white-space: nowrap;
}

/* ---------- 목록/기록 ---------- */
.tl-head { margin-bottom: 14px; }
.tl-head h2 { font-size: 22px; }
.tl-stats { color: var(--sub); font-size: 13px; margin-top: 6px; line-height: 1.5; white-space: pre-line; }
.tl-month { font-size: 14px; font-weight: 800; color: var(--brand); margin: 18px 0 8px; }
.tl-item {
  display: flex; gap: 12px; align-items: center; background: var(--card);
  border: 1px solid var(--line); border-radius: 16px; padding: 10px; margin-bottom: 8px;
  cursor: pointer;
}
.tl-item:active { background: var(--brand-soft); }
.tl-thumb {
  width: 56px; height: 56px; border-radius: 12px; flex: none;
  background: var(--brand-soft); display: flex; align-items: center; justify-content: center;
  font-size: 26px; overflow: hidden;
}
.tl-thumb img { width: 100%; height: 100%; object-fit: cover; }
.tl-thumb svg { display: block; }
.tl-body { min-width: 0; }
.tl-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-sub { font-size: 12.5px; color: var(--sub); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { text-align: center; color: var(--sub); line-height: 1.8; padding: 60px 0; }

/* ---------- settings ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px; margin-bottom: 12px;
}
.card h3 { font-size: 15px; margin-bottom: 8px; }
.card .sub { font-size: 12.5px; color: var(--sub); line-height: 1.6; margin: 8px 0; }
.card .btn { margin: 4px 6px 4px 0; }
.row { display: flex; gap: 8px; align-items: center; }

/* ---------- sheets ---------- */
.sheet-back { position: fixed; inset: 0; background: rgba(61,44,51,.4); z-index: 900; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
  background: #fff; border-radius: 22px 22px 0 0; box-shadow: var(--shadow);
  padding: 20px 18px calc(18px + var(--sab));
  max-height: 86vh; overflow-y: auto;
  animation: slideup .22s ease;
}
@keyframes slideup { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet h3 { margin-bottom: 10px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 16px; }
.sheet-actions .btn { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1.5px solid var(--line); border-radius: 999px; padding: 7px 13px;
  font-size: 14px; font-weight: 600; background: #fff;
}
.chip.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); }

/* 지역 시트 */
.rg-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.rg-head h3 { font-size: 20px; margin: 0; }
.rg-count { color: var(--sub); font-size: 13px; font-weight: 700; }
.rg-empty { color: var(--sub); font-size: 13.5px; padding: 10px 2px; }
.palette { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.pal-dot {
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid rgba(61, 44, 51, .12);
}
.pal-dot.on { border-color: var(--ink); box-shadow: 0 0 0 2px #fff inset; }
.pal-dot.clear {
  background: #fff; border: 1.5px dashed var(--line); color: var(--sub);
  font-size: 13px; display: flex; align-items: center; justify-content: center;
}
.pal-dot.custom {
  position: relative; overflow: hidden; cursor: pointer;
  background: conic-gradient(#ff9db0, #ffe08a, #a8e6c9, #a5d8ff, #cdb4f6, #ff9db0);
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.pal-dot.custom input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer; border: 0; padding: 0;
}
.pal-dot.custom:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; }

/* 사진 */
.photo-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.photo-thumb { position: relative; width: 74px; height: 74px; border-radius: 12px; overflow: hidden; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-thumb button {
  position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; font-size: 12px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}

/* detail */
.d-photos { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 12px; }
.d-photos img { height: 190px; border-radius: 14px; flex: none; max-width: 100%; object-fit: cover; }
.d-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.d-head h3 { margin: 0; }
.d-meta { color: var(--sub); font-size: 13px; margin-bottom: 8px; }
#dNote { white-space: pre-wrap; line-height: 1.6; font-size: 15px; }

/* toast */
#toast {
  position: fixed; bottom: calc(84px + var(--sab)); left: 50%; transform: translateX(-50%);
  background: rgba(61,44,51,.92); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; z-index: 2000; white-space: nowrap;
  animation: slideup .2s ease;
}

@media (min-width: 720px) {
  .sheet { left: 50%; right: auto; transform: translateX(-50%); width: 520px; border-radius: 22px; bottom: 24px; }
}
