:root {
    --bg: #f7f8fa;
    --panel: rgba(255, 255, 255, 0.92);
    --border: #e6e8ec;
    --text: #1f2733;
    --muted: #6b7480;
    --accent: #2563eb;
    --cave: #7c3aed;
    --restaurant: #e8590c;
    --village: #2f9e44;
    --shadow: 0 8px 30px rgba(16, 24, 40, 0.12);
    --radius: 14px;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    color: var(--text);
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

#map {
    width: 100%;
    height: 100vh;
    z-index: 0;
    background: var(--bg);
}

/* ---- App header (floating, top-center) — brand + search + distance ---- */
#app-header {
    position: fixed;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    max-width: calc(100vw - 130px);
    padding: 12px 18px;
    background: var(--panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.header-top {
    display: flex;
    align-items: baseline;
    gap: 12px;
    white-space: nowrap;
}

#app-header .brand {
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.01em;
}

#app-header .tagline {
    font-size: 13px;
    color: var(--muted);
}

.header-search {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-search #place-input {
    width: 320px;
    max-width: 60vw;
    padding: 9px 16px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.header-search #place-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.header-search #radius-size {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
    font-family: inherit;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    outline: none;
}

#search-status {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: 13px;
    color: #c0392b;
    background: var(--panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px 12px;
    box-shadow: var(--shadow);
}

#search-status:empty { display: none; }

@media (max-width: 640px) {
    #app-header { align-items: stretch; }
    .header-top .tagline { display: none; }
    .header-search { width: 100%; }
    .header-search #place-input { width: 100%; max-width: none; }
}

/* ---- Onboarding intro in the sidebar ---- */
.intro { color: var(--text); }
.intro-lead {
    font-size: 15px;
    font-weight: 600;
    margin: 4px 0 14px;
}
.steps {
    margin: 0 0 16px;
    padding-left: 20px;
}
.steps li {
    font-size: 13.5px;
    color: var(--muted);
    margin-bottom: 9px;
    line-height: 1.45;
}
.steps li b { color: var(--text); }
.intro-hint {
    font-size: 12.5px;
    color: var(--muted);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    line-height: 1.5;
}

/* ---- Leaflet control polish ---- */
.leaflet-bar,
.leaflet-control-layers {
    border: 1px solid var(--border) !important;
    border-radius: 12px !important;
    box-shadow: var(--shadow) !important;
    overflow: hidden;
}

.leaflet-control-layers {
    padding: 6px 4px;
}

.leaflet-control-layers-list {
    font-size: 13px;
}

.leaflet-bar a:first-child { border-top-left-radius: 12px; border-top-right-radius: 12px; }
.leaflet-bar a:last-child { border-bottom-left-radius: 12px; border-bottom-right-radius: 12px; }

/* ---- Legend (bottom-left, frosted glass) ---- */
#legend-box {
    position: fixed;
    left: 20px;
    bottom: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 9px;
    background: var(--panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 16px;
    font-size: 13px;
    color: var(--text);
}

#legend-box span {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---- Sidebar toggle (top-right) ---- */
#burger-button {
    position: fixed;
    top: 16px;
    right: 20px;
    z-index: 1100;
    width: 42px;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    box-shadow: var(--shadow);
    transition: transform 0.12s;
}

#burger-button:hover { transform: translateY(-1px); }

#burger-button span {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: var(--text);
}

/* ---- Sidebar (right slide-in) ---- */
#sidebar {
    position: fixed;
    top: 0;
    right: -420px;
    width: 420px;
    max-width: 92vw;
    height: 100vh;
    background: var(--bg);
    box-shadow: -10px 0 40px rgba(16, 24, 40, 0.18);
    transition: right 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 1050;
    display: flex;
    flex-direction: column;
}

#sidebar.open { right: 0; }

.sidebar-header {
    padding: 22px 18px 14px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, #fff, var(--bg));
}

.sidebar-title {
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -0.02em;
    margin-bottom: 12px;
}

#chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
    padding: 5px 12px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    color: var(--muted);
    transition: all 0.12s;
}

.chip-icon { width: 15px; height: 15px; }
.chip:not(.active) .chip-icon { opacity: 0.4; filter: grayscale(1); }
.chip:hover { border-color: #cfd4da; }

.chip.cat-Village.active { background: rgba(47, 158, 68, 0.12); border-color: var(--village); color: var(--village); }
.chip.cat-Restaurant.active { background: rgba(232, 89, 12, 0.12); border-color: var(--restaurant); color: var(--restaurant); }
.chip.cat-Cave.active { background: rgba(124, 58, 237, 0.12); border-color: var(--cave); color: var(--cave); }

#sidebar-content {
    overflow-y: auto;
    padding: 14px;
    flex: 1;
    color: var(--muted);
    font-size: 14px;
}

/* ---- Map marker hover cards (Leaflet tooltips) ---- */
.leaflet-tooltip.hover-card {
    padding: 0;
    border: none;
    border-radius: 12px;
    box-shadow: var(--shadow);
    background: #fff;
    overflow: hidden;
    font-family: inherit;
    white-space: normal;
    max-width: 320px; /* lift Leaflet's default 200px cap */
}

.leaflet-tooltip.hover-card::before { display: none; } /* hide default arrow */

.hover-card .hc { font-size: 12px; color: var(--text); }
.hover-card .hc:not(.hc-place) { padding: 9px 13px; max-width: 300px; }
.hover-card .hc:not(.hc-place) .hc-name { white-space: nowrap; }

.hover-card .hc-place { width: 210px; }
.hover-card .hc-photo { width: 100%; height: 104px; background: var(--bg); }
.hover-card .hc-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hover-card .hc-body { padding: 8px 11px; }

.hover-card .hc-name {
    font-weight: 650;
    font-size: 13px;
    color: #1f2733;
    line-height: 1.25;
}

.hover-card .hc-meta,
.hover-card .hc-sub {
    font-size: 12px;
    color: var(--muted);
    margin-top: 3px;
}

.hover-card .hc-star { color: #e8a400; }

/* ---- Card groups (bucketed by category) ---- */
.card-group { margin-bottom: 18px; }

.group-header {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    padding: 0 2px 8px;
    margin-bottom: 10px;
    border-bottom: 2px solid var(--border);
}

.group-icon { width: 16px; height: 16px; }

.group-count {
    margin-left: auto;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 1px 9px;
}

.group-header.cat-Village { color: var(--village); border-bottom-color: rgba(47, 158, 68, 0.4); }
.group-header.cat-Restaurant { color: var(--restaurant); border-bottom-color: rgba(232, 89, 12, 0.4); }
.group-header.cat-Cave { color: var(--cave); border-bottom-color: rgba(124, 58, 237, 0.4); }

.empty { color: var(--muted); }

/* ---- Place cards ---- */
.card-poi {
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 10px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
    transition: transform 0.12s, box-shadow 0.12s;
}

.card-poi:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(16, 24, 40, 0.1);
}

.card-poi.cat-Village { border-left-color: var(--village); }
.card-poi.cat-Restaurant { border-left-color: var(--restaurant); }
.card-poi.cat-Cave { border-left-color: var(--cave); }

.card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.card-name {
    font-weight: 650;
    font-size: 14.5px;
    color: var(--text);
    line-height: 1.25;
}

.zoom-btn {
    flex: none;
    border: none;
    background: var(--accent);
    color: #fff;
    border-radius: 8px;
    padding: 5px 11px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s;
}

.zoom-btn:hover { background: #1d4ed8; }

.card-body {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.card-photo {
    flex: none;
    display: block;
    width: 76px;
    height: 76px;
    border-radius: 10px;
    overflow: hidden;
}

.card-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.2s;
}

.card-photo:hover img { transform: scale(1.06); }

.card-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.card-rating {
    font-size: 13px;
    font-weight: 600;
    color: #1f2733;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-rating .rating { color: #e8a400; }
.card-rating .muted { color: var(--muted); font-weight: 500; }
.card-rating .price { color: var(--muted); font-weight: 600; }

.card-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 12px;
    font-size: 12.5px;
    color: var(--muted);
}

.card-meta span { display: flex; align-items: center; gap: 5px; }
.meta-dist { margin-left: auto; }

.card-link {
    font-size: 12.5px;
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.card-link:hover { text-decoration: underline; }
