:root {
    --bg: #000;
    --card: #0b0b0b;
    --line: #232323;
    --line-hi: #3a3a3a;
    --text: #ccc;
    --muted: #777;
    --link: #a8b8d0;
    --accent: #62a1ff;
    --ok: #6fbf73;
    --cl: #b48ae0;
    --rf: #e0805a;
}

* {
    box-sizing: border-box;
}

body {
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 2rem 1rem 4rem;
    font-size: 0.85rem;
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
}

header a {
    text-decoration: none;
}

.page-header .page-label {
    margin-bottom: 1.5rem;
}

button,
input,
select {
    font: inherit;
    color: inherit;
}

input,
select {
    background: #0d0d0d;
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 0.35rem 0.5rem;
    width: 100%;
    min-width: 0;
    color-scheme: dark;
}

input:focus,
select:focus,
button:focus-visible {
    outline: 1px solid var(--accent);
    outline-offset: 1px;
}

button {
    background: none;
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 0.3rem 0.6rem;
    cursor: pointer;
}

button:hover {
    border-color: var(--line-hi);
}

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

/* ---------- layout ---------- */
.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.25rem;
}

.map-wrap {
    position: relative;
    order: -1;
}

#map {
    height: 42vh;
    min-height: 260px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #111;
}

@media (min-width: 900px) {
    body {
        padding: 2.5rem 2rem;
    }

    .layout {
        grid-template-columns: 15rem minmax(0, 1fr) minmax(0, 0.9fr);
        align-items: start;
    }

    .map-wrap {
        order: 0;
        position: sticky;
        top: 1.5rem;
    }

    #map {
        height: calc(100vh - 3rem);
    }

    .filters {
        position: sticky;
        top: 1.5rem;
        max-height: calc(100vh - 3rem);
        overflow-y: auto;
        scrollbar-width: thin;
        scrollbar-color: #333 transparent;
        padding-right: 0.25rem;
    }

    .filters-toggle {
        display: none;
    }

    .filters form {
        display: block !important;
    }
}

@media (min-width: 1400px) {
    body {
        padding: 2.5rem 4rem;
    }

    .layout {
        grid-template-columns: 16rem minmax(0, 1fr) minmax(0, 1fr);
    }
}

/* ---------- filters ---------- */
.filters-toggle {
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.75rem;
}

.filters-toggle::after {
    content: ' +';
    color: var(--muted);
}

.filters-toggle[aria-expanded="true"]::after {
    content: ' −';
}

@media (max-width: 899px) {
    .filters form {
        display: none;
        padding-top: 0.75rem;
    }

    .filters.open form {
        display: block;
    }
}

.filters section {
    margin-bottom: 1.1rem;
}

.filters h2 {
    font-size: 0.72rem;
    font-weight: normal;
    color: var(--muted);
    letter-spacing: 0.05em;
    margin: 0 0 0.4rem;
}

.pair {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.place {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.4rem;
}

.place button {
    flex: none;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.chips button {
    padding: 0.2rem 0.55rem;
    font-size: 0.78rem;
}

.chips button.on {
    border-color: var(--accent);
    color: #fff;
    background: rgba(98, 161, 255, 0.12);
}

label.check {
    display: flex;
    align-items: baseline;
    gap: 0.45rem;
    margin: 0.2rem 0;
    cursor: pointer;
}

label.check input {
    width: auto;
    flex: none;
    accent-color: var(--accent);
}

label.inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.45rem;
    color: var(--muted);
    white-space: nowrap;
}

label.inline select,
label.inline input {
    flex: 1;
}

.filters input[type="search"] + label.inline {
    margin-top: 0.45rem;
}

.hint {
    font-size: 0.72rem;
    color: var(--muted);
    margin: 0.35rem 0 0;
}

.hint:empty {
    display: none;
}

.deeplinks {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.deeplinks a {
    font-size: 0.78rem;
    color: var(--link);
    text-decoration: none;
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 0.2rem 0.55rem;
}

.deeplinks a:hover {
    border-color: var(--line-hi);
    color: #fff;
}

.zones {
    list-style: none;
    padding: 0;
    margin: 0 0 0.4rem;
}

.zones li {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.3rem;
}

.zones .zname {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.zones input {
    width: 3.6rem;
    flex: none;
    padding: 0.15rem 0.3rem;
}

.zones .mi {
    color: var(--muted);
    font-size: 0.75rem;
}

.zones button {
    border: none;
    color: var(--muted);
    padding: 0 0.25rem;
}

.zones button:hover {
    color: #fff;
}

.linkish {
    border: none;
    padding: 0;
    margin-top: 0.4rem;
    color: var(--link);
    font-size: 0.78rem;
}

.linkish.on {
    color: #e0805a;
}

#map.picking {
    cursor: crosshair;
}

.reset {
    color: var(--muted);
    font-size: 0.78rem;
}

/* ---------- results ---------- */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.toolbar select {
    width: auto;
}

.tabs {
    display: flex;
    gap: 0.3rem;
}

.tabs button.on {
    border-color: var(--accent);
    color: #fff;
}

.status {
    color: var(--muted);
    font-size: 0.78rem;
    margin: 0.75rem 0;
    min-height: 1.2em;
}

.status .err {
    color: #e0524a;
}

.cards {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 0.6rem;
}

.card {
    display: grid;
    grid-template-columns: 8.5rem minmax(0, 1fr);
    gap: 0.75rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--card);
    padding: 0.5rem;
    transition: border-color 150ms ease;
}

.card:hover,
.card.hl {
    border-color: var(--line-hi);
}

.card.hl {
    border-color: var(--accent);
}

.card.hidden-item {
    opacity: 0.45;
}

.thumb {
    display: block;
    aspect-ratio: 4 / 3;
    border-radius: 4px;
    overflow: hidden;
    background: #151515;
}

.thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.thumb .none {
    display: flex;
    height: 100%;
    align-items: center;
    justify-content: center;
    color: #444;
    font-size: 0.7rem;
}

.body {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
}

.price {
    color: #eee;
    font-size: 0.98rem;
}

.price small {
    color: var(--muted);
    font-size: 0.72rem;
}

.acts {
    display: flex;
    gap: 0.25rem;
    flex: none;
}

.acts button {
    border: none;
    padding: 0.05rem 0.3rem;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1;
}

.acts button:hover {
    color: #fff;
}

.acts button.saved {
    color: #f0c050;
}

.specs {
    color: #bbb;
}

.title {
    color: var(--link);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.title:hover {
    color: #fff;
}

.where {
    color: var(--muted);
    font-size: 0.76rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.2rem;
}

.tag {
    font-size: 0.68rem;
    border: 1px solid var(--line);
    border-radius: 3px;
    padding: 0 0.35rem;
    color: #aaa;
}

.tag.good {
    color: var(--ok);
    border-color: rgba(111, 191, 115, 0.35);
}

.meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem 0.6rem;
    font-size: 0.7rem;
    color: var(--muted);
    margin-top: auto;
    padding-top: 0.25rem;
}

.meta a {
    color: var(--link);
    text-decoration: none;
}

.meta a:hover {
    color: #fff;
}

.src {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.src::before {
    content: '';
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: var(--rf);
}

.src.craigslist::before {
    background: var(--cl);
}

.new {
    color: var(--accent);
}

.more {
    display: block;
    margin: 1rem auto 0;
}

@media (max-width: 480px) {
    .card {
        grid-template-columns: 6.5rem minmax(0, 1fr);
    }
}

/* ---------- map ---------- */
.search-area {
    position: absolute;
    top: 0.75rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 500;
    background: #000;
    border-color: var(--accent);
    color: #fff;
    padding: 0.4rem 0.9rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}

.pin {
    background: #111;
    border: 1px solid var(--rf);
    color: #eee;
    border-radius: 10px;
    padding: 0 0.4rem;
    font: 11px/18px PTMono, monospace;
    white-space: nowrap;
    transform: translate(-50%, -50%);
    display: inline-block;
    cursor: pointer;
}

.pin.craigslist {
    border-color: var(--cl);
}

/* Zoomed out: a dot per listing; the highlighted one still shows its price. */
.pin.dot {
    width: 9px;
    height: 9px;
    padding: 0;
    border-radius: 50%;
    border-width: 2px;
    background: #000;
}

.pin.dot.hl {
    width: auto;
    height: auto;
    padding: 0 0.4rem;
    border-radius: 10px;
}

.pin.dot.hl::after {
    content: attr(data-label);
}

.dark-tiles {
    filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.85) saturate(0.4);
}

.pin.hl {
    background: var(--accent);
    border-color: var(--accent);
    color: #000;
    z-index: 1000;
}

.pin.saved {
    box-shadow: 0 0 0 2px #f0c050;
}

.leaflet-marker-icon.pin-icon {
    background: none;
    border: none;
    width: 0 !important;
    height: 0 !important;
    overflow: visible;
}

.leaflet-container {
    font-family: PTMono, monospace;
    background: #111;
}

.leaflet-control-attribution {
    background: rgba(0, 0, 0, 0.6) !important;
    color: #666;
}

.leaflet-control-attribution a {
    color: #888;
}

.leaflet-bar a {
    background: #111;
    color: #ccc;
    border-bottom-color: #222;
}

.leaflet-bar a:hover {
    background: #222;
}
