:root {
    --cream: #f8fafc;
    --cream-soft: #f1f5f9;
    --paper: #ffffff;
    --ink: #0f172a;
    --ink-soft: #334155;
    --muted: #64748b;
    --line: #e2e8f0;
    --line-strong: #cbd5e1;
    --gold: #f59e0b;
    --gold-deep: #92400e;
    --gold-soft: #fffbeb;
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-soft: #eff6ff;
    --platinum: #f1f5f9;
    --shadow-sm: 0 1px 2px 0 rgb(15 23 42 / 0.06);
    --shadow-md: 0 10px 25px rgb(15 23 42 / 0.12);
    --shadow-xl: 0 22px 55px rgb(15 23 42 / 0.18);
    --font-main: 'Outfit', sans-serif;
    --font-display: 'Instrument Serif', serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

html,
body {
    height: 100%;
}

body {
    font-family: var(--font-main);
    background: var(--cream);
    color: var(--ink);
    overflow: hidden;
}

button,
input,
select {
    font: inherit;
}

.icon {
    width: 1.25em;
    height: 1.25em;
    fill: currentColor;
    display: inline-block;
    vertical-align: text-bottom;
    flex-shrink: 0;
}

.container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.map-container {
    position: fixed;
    inset: 0;
    background: #e5e7eb;
    z-index: 1;
}

#map {
    width: 100%;
    height: 100%;
    background: var(--cream);
}

.sidebar {
    position: fixed;
    inset: 0;
    z-index: 20;
    pointer-events: none;
}

.floating-search-header,
.results-sheet {
    pointer-events: auto;
}

.floating-search-header {
    position: fixed;
    top: max(0.75rem, env(safe-area-inset-top));
    left: 0.75rem;
    right: 0.75rem;
    z-index: 35;
    border: 1px solid rgb(226 232 240 / 0.94);
    background: rgb(255 255 255 / 0.94);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(18px);
}

.header {
    padding: 0.95rem 1rem 0.25rem;
}

.title {
    color: var(--ink);
    font-family: var(--font-display);
    font-size: 2.55rem;
    font-weight: 400;
    letter-spacing: 0;
    line-height: 0.9;
}

.subtitle {
    margin-top: 0.55rem;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.25;
}

#search-container {
    padding: 0.55rem 0.75rem 0.75rem;
}

.search-wrapper {
    position: relative;
}

.search-icon {
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
    z-index: 10;
    width: 1.05rem;
    height: 1.05rem;
}

.clear-search {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    transition: all .2s;
    z-index: 10;
    width: 1.45rem;
    height: 1.45rem;
}

.clear-search:hover {
    background: var(--line);
    color: var(--ink);
}

.clear-search:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

#restaurant-search {
    width: 100%;
    padding: .86rem 2.4rem .86rem 2.55rem;
    border: 1px solid var(--line);
    border-radius: 4px;
    font-size: 1rem;
    color: var(--ink);
    background: var(--cream);
    transition: border-color .2s, box-shadow .2s, background .2s;
}

#restaurant-search::placeholder {
    color: #94a3b8;
}

#restaurant-search:focus {
    outline: none;
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgb(37 99 235 / 0.12);
}

.results-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: min(56vh, 32rem);
    display: flex;
    flex-direction: column;
    background: var(--paper);
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 18px 18px 0 0;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

.sheet-handle {
    width: 2.75rem;
    height: 4px;
    border-radius: 999px;
    background: var(--line-strong);
    margin: 0.65rem auto 0.4rem;
    flex: 0 0 auto;
}

.filters-container {
    padding: 0.7rem 0.85rem 0.9rem;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.clear-all-filters {
    visibility: hidden;
    opacity: 0;
    border: 0;
    background: transparent;
    color: var(--primary);
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0;
    transition: opacity .2s, color .2s;
}

.clear-all-filters.visible {
    visibility: visible;
    opacity: 1;
}

.clear-all-filters:hover {
    color: var(--primary-dark);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.filter-section {
    min-width: 0;
    position: relative;
}

.filter-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.filter-label {
    font-size: 0.66rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.45rem;
}

.chip-row {
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
    padding: 0.04rem 1.1rem 0.16rem 0;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    mask-image: linear-gradient(to right, #000 calc(100% - 1.25rem), transparent);
}

.chip-row::-webkit-scrollbar {
    display: none;
}

.filter-chip {
    flex: 0 0 auto;
    max-width: 11rem;
    min-height: 2.05rem;
    padding: 0.42rem 0.68rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 0.78rem;
    background: #fff;
    color: var(--ink-soft);
    transition: border-color .2s, background .2s, color .2s, box-shadow .2s;
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.filter-chip:hover {
    border-color: var(--line-strong);
    background: var(--cream);
}

.filter-chip.active {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 10px rgb(37 99 235 / 0.16);
}

.filter-chip:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.12);
}

.restaurant-list {
    flex: 1;
    overflow-y: scroll;
    scrollbar-gutter: stable;
    padding: 0.85rem 0.85rem calc(1rem + env(safe-area-inset-bottom));
    background:
        linear-gradient(180deg, rgb(255 255 255 / 0.98), rgb(248 250 252 / 0.98)),
        var(--cream);
}

.restaurant-list::-webkit-scrollbar {
    width: 6px;
}

.restaurant-list::-webkit-scrollbar-track {
    background: transparent;
}

.restaurant-list::-webkit-scrollbar-thumb {
    background-color: var(--line-strong);
    border-radius: 20px;
}

.empty-state {
    text-align: center;
    padding: 2rem 1.25rem;
    color: var(--muted);
    font-size: 0.95rem;
    background: var(--paper);
    border: 1px dashed var(--line-strong);
    border-radius: 6px;
    margin: 0.5rem 0;
}

.restaurant-card {
    display: block;
    inline-size: 100%;
    max-inline-size: 100%;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease, background .2s ease;
    position: relative;
    overflow: hidden;
}

.restaurant-card::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--primary);
    opacity: 0.32;
}

.restaurant-card.starred::before {
    background: var(--gold);
    opacity: 1;
}

.restaurant-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    border-color: var(--line-strong);
}

.restaurant-card.active {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: inset 0 0 0 1px var(--primary), var(--shadow-sm);
}

.card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.65rem;
}

.card-title-block {
    flex: 1 1 auto;
    min-width: 0;
}

.restaurant-card h3 {
    font-family: var(--font-display);
    font-size: 1.55rem;
    font-weight: 400;
    line-height: 0.98;
    letter-spacing: 0;
    color: var(--ink);
    min-width: 0;
    overflow-wrap: anywhere;
    margin-bottom: 0.25rem;
}

.card-badges {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.35rem;
    flex: 0 1 auto;
    max-width: 46%;
    min-width: 0;
}

.stars-badge,
.rating-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0.28rem 0.5rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
    white-space: nowrap;
    max-width: 100%;
}

.stars-badge {
    background: var(--gold-soft);
    color: var(--gold-deep);
    border: 1px solid rgb(184 138 45 / 0.45);
}

.stars-badge .icon {
    width: 0.82rem;
    height: 0.82rem;
    fill: var(--gold);
}

.rating-badge {
    background: var(--cream-soft);
    color: var(--ink-soft);
    border: 1px solid var(--line);
}

.rating-badge.unrated {
    color: var(--muted);
    font-weight: 600;
}

.rating-badge .icon {
    width: 0.82rem;
    height: 0.82rem;
    fill: var(--muted);
}

.cuisine-row {
    color: var(--muted);
    font-family: var(--font-main);
    font-size: 0.88rem;
    font-weight: 500;
    line-height: 1.25;
}

.location-row {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    color: var(--muted);
    font-family: var(--font-main);
    font-size: .84rem;
    font-weight: 400;
    line-height: 1.45;
}

.location-row .icon {
    margin-top: 3px;
    width: 1rem;
    height: 1rem;
    color: var(--muted);
}

.custom-marker {
    background: none;
    border: none;
}

.marker-circle {
    width: 34px;
    height: 34px;
    background: var(--primary);
    color: var(--paper);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 18px rgb(37 99 235 / 0.36);
    border: 2px solid var(--paper);
}

.marker-circle.starred {
    background: var(--gold);
    color: #fffaf0;
    box-shadow: 0 8px 22px rgb(184 138 45 / 0.45);
    border-color: #fff7df;
}

.minimal-popup .leaflet-popup-content-wrapper {
    border-radius: 6px;
    box-shadow: var(--shadow-md);
    padding: 0;
    overflow: hidden;
    background: var(--paper);
    border: 1px solid var(--line);
}

.minimal-popup .leaflet-popup-tip {
    display: none;
}

.minimal-popup .leaflet-popup-content {
    margin: 0 !important;
    width: auto !important;
    min-width: 170px;
    max-width: 260px;
}

.custom-popup {
    padding: 0.85rem 1rem;
}

.custom-popup h3 {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 400;
    line-height: 0.95;
    letter-spacing: 0;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.35rem;
}

.popup-type {
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

@media (max-width: 380px) {
    .results-sheet {
        height: 58vh;
    }
}

@media (min-width: 769px) {
    .container {
        display: flex;
    }

    .map-container {
        position: relative;
        flex: 1;
        height: 100%;
        margin-left: 430px;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 430px;
        right: auto;
        background: var(--paper);
        border-right: 1px solid var(--line);
        box-shadow: var(--shadow-xl);
        display: flex;
        flex-direction: column;
        pointer-events: auto;
    }

    .floating-search-header {
        position: static;
        inset: auto;
        border: 0;
        border-bottom: 1px solid var(--line);
        box-shadow: none;
        backdrop-filter: none;
        background: var(--paper);
        flex: 0 0 auto;
    }

    .header {
        padding: 1.4rem 1.5rem 0.5rem;
    }

    .title {
        font-size: 3.2rem;
    }

    #search-container {
        padding: 0.65rem 1.25rem 1.2rem;
    }

    .results-sheet {
        position: static;
        height: auto;
        min-height: 0;
        flex: 1;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .sheet-handle {
        display: none;
    }

    .filters-container {
        padding: 1rem 1.25rem;
    }

    .restaurant-list {
        padding: 1.25rem 1.25rem 1rem;
    }

    .restaurant-card {
        padding: 1.15rem;
        margin-bottom: 0.95rem;
    }

    .restaurant-card h3 {
        font-size: 1.7rem;
    }

}

@media (min-width: 1180px) {
    .sidebar {
        width: 470px;
    }

    .map-container {
        margin-left: 470px;
    }
}
