:root {
  color-scheme: light;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);

  --accent: #007aff;
  --meta: #3d82ab;
  --danger: #ff3b30;
  --want: #ff9500;
  --visited: #34c759;
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #1c1c1e;
  --text-secondary: #8e8e93;
  --separator: rgba(60, 60, 67, 0.13);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font-family: inherit; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
.font-emphasis { font-family: 'Paperlogy', 'Pretendard', -apple-system, sans-serif; }

/* Login */
#login-screen {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 32px 28px;
  max-width: 360px;
  margin: 18vh auto 0;
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
#login-screen h1 {
  font-family: 'Paperlogy', 'Pretendard', -apple-system, sans-serif;
  text-align: center;
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}
#login-screen input {
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--separator);
  background: var(--bg);
  font-size: 1rem;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
#login-screen input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}
#login-screen button {
  padding: 14px 16px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: white;
  font-weight: 600;
  font-size: 1rem;
  transition: transform 0.08s ease, opacity 0.08s ease;
}
#login-screen button:active { transform: scale(0.97); opacity: 0.9; }
.error { color: var(--danger); font-size: 0.9rem; margin: 0; }

/* Map screen */
#map-screen { position: relative; height: 100dvh; }
#map { width: 100%; height: 100%; background: var(--bg); }
#search-bar {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 12px;
  right: 12px;
  z-index: 10;
}
.icon { width: 18px; height: 18px; flex-shrink: 0; }
.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--shadow);
  padding: 0 14px;
}
.search-input-wrap .icon-search { color: var(--text-secondary); }
#search-input {
  flex: 1;
  min-width: 0;
  padding: 12px 0 12px 10px;
  border: none;
  background: transparent;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
}
#search-input:focus { outline: none; }
.search-clear-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  padding: 0;
  margin-left: 6px;
  background: var(--separator);
  color: var(--text-secondary);
}
.search-clear-btn .icon { width: 12px; height: 12px; }
.search-clear-btn:active { transform: scale(0.9); }
#search-results:empty { display: none; }
#search-results {
  list-style: none;
  margin: 8px 0 0;
  padding: 6px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  max-height: 50vh;
  overflow-y: auto;
}
#search-results li {
  padding: 12px 12px;
  border-radius: 10px;
  font-size: 0.95rem;
}
#search-results li:active { background: var(--bg); }

/* Detail sheet */
#detail-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  padding: 4px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.18);
  z-index: 20;
  animation: sheet-up 0.22s ease-out;
}
@keyframes sheet-up {
  from { transform: translateY(16px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}
.sheet-top {
  position: relative;
  padding: 6px 0;
}
.sheet-handle {
  width: 36px;
  height: 5px;
  border-radius: 3px;
  background: var(--separator);
  margin: 0 auto;
  touch-action: none;
  padding: 6px 40px;
  background-clip: content-box;
  box-sizing: content-box;
}
#detail-sheet-close {
  position: absolute;
  top: 4px;
  right: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--separator);
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
#detail-sheet-close:active { transform: scale(0.92); }
.detail-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 4px;
}
#detail-sheet-content h2 {
  font-family: 'Paperlogy', 'Pretendard', -apple-system, sans-serif;
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.detail-address {
  margin: 0 0 6px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.award-banner {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 700;
  color: white;
}
.award-banner .icon { width: 13px; height: 13px; }
.award-banner.award-michelin { background: #E31937; }
.award-banner.award-ushulang { background: #2D5FA3; }
.detail-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 0 12px;
  color: var(--meta);
  font-weight: 500;
  font-size: 0.88rem;
}
.detail-meta a { color: var(--meta); }
.detail-meta .dot { color: var(--text-secondary); margin: 0 2px; }
.detail-meta a.btn-kakao-link {
  display: inline-flex;
  align-items: center;
  padding: 4.5px 13.5px;
  border-radius: 9999px;
  border: none;
  background: var(--meta);
  color: white;
  font-family: 'Noto Sans KR', 'Pretendard', sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
}
.btn-kakao-link:active { transform: scale(0.97); }

.photo-gallery {
  display: flex;
  gap: 8px;
  margin: 0 0 16px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.photo-thumb {
  flex-shrink: 0;
  width: 84px;
  height: 84px;
  border-radius: 12px;
  border: none;
  padding: 0;
  overflow: hidden;
  background: var(--bg);
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-add-tile {
  flex-shrink: 0;
  width: 84px;
  height: 84px;
  border-radius: 12px;
  border: 1px dashed var(--separator);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}
.photo-add-tile:active { background: var(--bg); }

#photo-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
}
#photo-lightbox-img { max-width: 92vw; max-height: 80vh; border-radius: 12px; object-fit: contain; }
#photo-lightbox-close,
#photo-lightbox-delete {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top, 0px));
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}
#photo-lightbox-close { right: 16px; }
#photo-lightbox-delete { left: 16px; color: #ff6b60; }

.detail-status-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 16px;
}
.status-item { display: flex; flex-direction: column; gap: 6px; }
.status-chip {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 600;
}
.status-chip.status-want_to_go { background: color-mix(in srgb, var(--want) 16%, white); color: color-mix(in srgb, var(--want) 65%, black); }
.status-chip.status-visited { background: color-mix(in srgb, var(--visited) 16%, white); color: color-mix(in srgb, var(--visited) 55%, black); }
.status-chip.has-review { cursor: pointer; }
.status-rating { opacity: 0.75; }
.review-indicator { opacity: 0.75; }
.status-review {
  margin: 0;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 10px;
  font-size: 0.85rem;
  color: var(--text);
  white-space: pre-wrap;
}
.detail-status-empty {
  margin: 0 0 16px;
  padding: 14px;
  border: 1px dashed var(--separator);
  border-radius: 12px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.88rem;
}
.rating-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
}
.rating-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}
.spoons { display: flex; gap: 1px; }
.rating-value { font-size: 0.85rem; font-weight: 600; color: var(--text); margin-left: 4px; }
.spoon-btn {
  position: relative;
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  padding: 0;
  transition: transform 0.08s ease;
}
.spoon-btn:active { transform: scale(0.85); }
.spoon-btn .icon {
  position: absolute;
  top: 0;
  left: 0;
  width: 32px;
  height: 32px;
  transform: rotate(-25deg);
}
.spoon-btn .spoon-empty { color: var(--separator); }
.spoon-btn .spoon-filled { color: #ffb400; }

.review-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 16px;
}
#review-input {
  width: 100%;
  min-height: 64px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--separator);
  background: var(--bg);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
  resize: vertical;
}
#review-input:focus { outline: none; border-color: var(--meta); }
.btn-review-save {
  align-self: flex-end;
  padding: 7px 16px;
  border-radius: 9999px;
  border: none;
  background: var(--meta);
  color: white;
  font-size: 0.85rem;
  font-weight: 600;
}
.btn-review-save:active { transform: scale(0.96); }

.detail-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.btn-status {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 10px;
  border-radius: 9999px;
  border: 1px solid var(--separator);
  background: transparent;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: transform 0.08s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn-status:active { transform: scale(0.97); }
.btn-status[data-action="want_to_go"] .icon { color: var(--want); }
.btn-status[data-action="visited"] .icon { color: var(--visited); }
.btn-status.active[data-action="want_to_go"] {
  background: var(--want);
  border-color: var(--want);
  color: white;
}
.btn-status.active[data-action="visited"] {
  background: var(--visited);
  border-color: var(--visited);
  color: white;
}
.btn-status.active .icon { color: white; }
.btn-delete {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 10px;
  border-radius: 9999px;
  border: 1px solid rgba(255, 59, 48, 0.28);
  background: transparent;
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 500;
}
.btn-delete:active { transform: scale(0.97); }
