/* ─── Reset & base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg:          #f5f5f7;
  --surface:     #ffffff;
  --border:      #e0e0e5;
  --border-soft: #ebebef;
  --text:        #1c191a;
  --muted:       #6b6b73;
  --hover:       #ededf0;
  --shadow:      0 1px 4px rgba(0,0,0,0.06);
  --shadow-lg:   0 4px 20px rgba(0,0,0,0.10);
  --radius:      10px;
  --sidebar-w:   340px;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

strong { font-weight: 600; }

/* ─── Layout ─────────────────────────────────────────────────────────────────── */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ─── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  position: relative;
  z-index: 10;
}

.sidebar__header {
  padding: 16px 20px 0;
  flex-shrink: 0;
  background-color: var(--surface);
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 36px 36px;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 14px;
  margin-bottom: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.sidebar-logo {
  width: 26px;
  height: 26px;
  animation: spin 10s linear infinite;
  flex-shrink: 0;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0;
}

.city-name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.spot-count { font-size: 12px; color: var(--muted); margin-top: 3px; }

.topbar__right { display: flex; align-items: center; gap: 6px; margin-top: 3px; }

.avatar-stack { display: flex; align-items: center; }

.avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; color: #fff;
  margin-left: -6px;
}
.avatar:first-child { margin-left: 0; }

.friends-label { font-size: 11px; color: var(--muted); }

/* Filters */
.filters {
  display: flex; gap: 5px;
  padding: 14px 20px 14px;
  overflow-x: auto; scrollbar-width: none; flex-shrink: 0;
}
.filters::-webkit-scrollbar { display: none; }

.pill {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px; font-weight: 500;
  padding: 4px 12px; border-radius: 20px;
  white-space: nowrap; cursor: pointer; font-family: inherit;
  transition: all 0.12s;
}
.pill:hover { background: var(--hover); }
.pill--active { background: var(--text); color: #fff; border-color: var(--text); }

.sidebar__divider { height: 1px; background: var(--border-soft); flex-shrink: 0; }

.sidebar__scroll {
  flex: 1; overflow-y: auto;
  padding: 14px 20px 80px;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.sidebar__scroll::-webkit-scrollbar { width: 4px; }
.sidebar__scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.section-label {
  font-size: 10px; font-weight: 600; color: var(--muted);
  letter-spacing: 0.8px; text-transform: uppercase;
  margin-bottom: 8px; margin-top: 16px;
}
.section-label:first-child { margin-top: 0; }

/* ─── Guide card ──────────────────────────────────────────────────────────────── */
.guide-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 10px;
}
.guide-card__eyebrow { font-size: 10px; color: var(--muted); margin-bottom: 4px; }
.guide-card__title { font-size: 15px; font-weight: 700; letter-spacing: -0.3px; margin-bottom: 2px; }
.guide-card__sub { font-size: 11px; color: var(--muted); margin-bottom: 12px; }
.guide-card__chips {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px;
}
.guide-card__chips::-webkit-scrollbar { display: none; }

.guide-chip {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 7px; padding: 5px 10px; flex-shrink: 0; cursor: pointer; transition: background 0.1s;
}
.guide-chip:hover { background: var(--hover); }
.guide-chip__name { font-size: 12px; font-weight: 500; white-space: nowrap; }
.guide-chip__note { font-size: 10px; color: var(--muted); margin-top: 1px; white-space: nowrap; }

/* ─── Place list ──────────────────────────────────────────────────────────────── */
.place-list { display: flex; flex-direction: column; gap: 6px; }

.place-item {
  padding: 12px 12px; border-radius: var(--radius); cursor: pointer;
  transition: border-color 0.1s, background 0.1s;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.place-item:hover { background: var(--hover); border-color: #ccc; }
.place-item--active { background: var(--bg); border-color: #bbb; box-shadow: none; }

.place-item__note {
  font-size: 14px; font-weight: 600; line-height: 1.35; margin-bottom: 7px;
}
.place-item__quote { color: #d3d1cb; }

.place-item__meta {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.place-item__name { font-size: 12px; font-weight: 500; }
.place-item__detail { font-size: 11px; color: var(--muted); margin-top: 1px; }
.place-item__emoji { font-size: 18px; flex-shrink: 0; }

.place-item__by {
  display: flex; align-items: center; gap: 5px;
  margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border-soft);
  font-size: 11px; color: var(--muted);
}

.mini-avatar {
  width: 16px; height: 16px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 7px; font-weight: 700; color: #fff; flex-shrink: 0;
}

.empty-state {
  text-align: center; padding: 32px 16px;
  font-size: 13px; color: var(--muted); line-height: 1.6;
}

/* ─── Footer ──────────────────────────────────────────────────────────────────── */
.sidebar__footer {
  position: absolute; bottom: 0; left: 0; width: var(--sidebar-w);
  padding: 12px 20px; background: var(--surface);
  border-top: 1px solid var(--border-soft);
  display: flex; gap: 8px; z-index: 11;
}

.btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-family: inherit; font-size: 13px; font-weight: 600;
  border-radius: 8px; cursor: pointer; transition: background 0.12s; border: none;
}
.btn--primary { flex: 1; background: var(--text); color: #fff; padding: 10px; }
.btn--primary:hover { background: #1a1814; }
.btn--secondary {
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text); padding: 10px 14px;
}
.btn--secondary:hover { background: var(--hover); }

/* ─── Map ─────────────────────────────────────────────────────────────────────── */
.map-container { flex: 1; position: relative; overflow: hidden; }
#map { position: absolute; inset: 0; }

.map-search {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 12;
  width: min(430px, calc(100% - 32px));
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.94);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(4px);
}

.map-search .search-input-wrap { margin-bottom: 0; }

.map-search__results {
  margin-top: 6px;
  max-height: 300px;
  overflow-y: auto;
}

.search-result__type {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 10px;
  text-transform: capitalize;
}

.locate-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 12;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255,255,255,0.94);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.locate-btn:hover {
  background: #fff;
}

.map-empty-state {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 12;
  background: rgba(255,255,255,0.95);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 11px 14px;
  min-width: 240px;
  max-width: min(90vw, 360px);
  text-align: center;
}

.map-empty-state__title {
  font-size: 13px;
  font-weight: 700;
}

.map-empty-state__body {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
}

.mapboxgl-ctrl-bottom-right { bottom: 24px; right: 16px; }
.mapboxgl-ctrl-group {
  border-radius: 8px !important;
  box-shadow: var(--shadow-lg) !important;
  border: 1px solid var(--border) !important;
}

/* ─── Pins ────────────────────────────────────────────────────────────────────── */
.map-pin {
  cursor: pointer; width: 20px; height: 24px;
  display: flex; align-items: flex-start; justify-content: center;
}

.pin-dot {
  width: 20px; height: 20px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2.5px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  transition: transform 0.15s; flex-shrink: 0;
}
.map-pin:hover .pin-dot { transform: rotate(-45deg) scale(1.15); }
.map-pin--active .pin-dot { transform: rotate(-45deg) scale(1.2); box-shadow: 0 3px 12px rgba(0,0,0,0.25); }
.map-pin--preview .pin-dot { opacity: 0.7; border-style: dashed; }

/* ─── Popup ───────────────────────────────────────────────────────────────────── */
.mapboxgl-popup-content {
  padding: 0 !important; border-radius: 12px !important;
  overflow: hidden !important; border: 1px solid var(--border) !important;
  box-shadow: var(--shadow-lg) !important;
}
.mapboxgl-popup-tip { display: none !important; }

.popup-img {
  width: 100%; height: 64px; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; border-bottom: 1px solid var(--border-soft);
}
.popup-body { padding: 11px 13px 13px; }
.popup-note { font-size: 14px; font-weight: 600; line-height: 1.3; margin-bottom: 7px; }
.popup-quote { color: #d3d1cb; }
.popup-name { font-size: 12px; font-weight: 500; }
.popup-detail { font-size: 11px; color: var(--muted); margin-top: 1px; margin-bottom: 9px; }
.popup-by {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--muted);
  padding-top: 8px; border-top: 1px solid var(--border-soft);
}
.popup-avatar {
  width: 16px; height: 16px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 7px; font-weight: 700; color: #fff; flex-shrink: 0;
}

/* ─── Drawer ──────────────────────────────────────────────────────────────────── */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.18);
  z-index: 40; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.overlay--visible { opacity: 1; pointer-events: all; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 360px;
  background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: -4px 0 24px rgba(0,0,0,0.08);
  z-index: 50; display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.22s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.drawer--open { transform: translateX(0); }

.drawer__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 20px 16px; border-bottom: 1px solid var(--border-soft); flex-shrink: 0;
}
.drawer__title { font-size: 16px; font-weight: 700; letter-spacing: -0.3px; }
.drawer__close {
  width: 28px; height: 28px; border-radius: 6px;
  background: var(--bg); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 16px; color: var(--muted); font-family: inherit;
  transition: background 0.1s;
}
.drawer__close:hover { background: var(--hover); color: var(--text); }

.drawer__body { flex: 1; overflow-y: auto; padding: 20px; }

.search-input-wrap { position: relative; margin-bottom: 12px; }
.search-icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 14px; pointer-events: none;
}
.drawer-search-input {
  width: 100%; padding: 10px 12px 10px 34px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; font-family: inherit; color: var(--text);
  outline: none; transition: border-color 0.15s;
}
.drawer-search-input:focus { border-color: #aaa; }
.drawer-search-input::placeholder { color: var(--muted); }

.search-results { display: flex; flex-direction: column; gap: 1px; }
.search-result { padding: 11px 12px; border-radius: 8px; cursor: pointer; transition: background 0.1s; }
.search-result:hover { background: var(--hover); }
.search-result__name { font-size: 13px; font-weight: 500; }
.search-result__address {
  font-size: 11px; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.search-result--loading, .search-result--empty {
  color: var(--muted); font-size: 13px; cursor: default; padding: 12px;
}
.search-result--loading:hover, .search-result--empty:hover { background: none; }

.note-phase { display: none; }

.selected-place-preview {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; margin-bottom: 20px;
}
.selected-place-preview__emoji { font-size: 28px; flex-shrink: 0; }
.selected-place-preview__name { font-size: 14px; font-weight: 600; line-height: 1.3; }
.selected-place-preview__address { font-size: 11px; color: var(--muted); margin-top: 2px; }

.field-label {
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 7px;
}

.note-input {
  width: 100%; padding: 11px 13px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; font-size: 15px; font-weight: 600;
  font-family: inherit; color: var(--text); outline: none;
  transition: border-color 0.15s; resize: none; min-height: 52px;
}
.note-input:focus { border-color: #aaa; }
.note-input::placeholder { color: var(--muted); font-weight: 400; }

.note-hint { font-size: 11px; color: var(--muted); margin-top: 5px; margin-bottom: 20px; }

.guide-select {
  width: 100%; padding: 9px 12px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px; font-family: inherit; color: var(--text);
  outline: none; cursor: pointer; margin-bottom: 24px;
}
.guide-select:focus { border-color: #aaa; }

.drawer__footer {
  padding: 16px 20px; border-top: 1px solid var(--border-soft);
  display: flex; gap: 8px; flex-shrink: 0;
}

@media (max-width: 900px) {
  :root { --sidebar-w: 300px; }

  .map-search {
    top: 12px;
    left: 12px;
    width: calc(100% - 24px);
  }

  .locate-btn {
    top: 12px;
    right: 12px;
  }
}

@media (max-width: 720px) {
  .sidebar { width: 100%; max-width: 300px; }
}

/* ─── Token prompt ────────────────────────────────────────────────────────────── */
.token-prompt {
  display: none; position: fixed; inset: 0;
  background: rgba(245,245,247,0.97); z-index: 100;
  flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 32px; text-align: center;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 36px 36px;
}
.token-prompt__title { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; }
.token-prompt__body { font-size: 14px; color: var(--muted); line-height: 1.6; max-width: 400px; }
.token-prompt__code {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 20px; font-family: monospace;
  font-size: 13px; margin: 8px 0;
}
