#list-toolbar {
    display: flex;
    gap: 8px;
    margin: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-subtle);
}

#search-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}

#search {
    width: 100%;
    padding: 6px 28px 6px 8px;
    font: inherit;
    box-sizing: border-box;
    border: 1px solid transparent;
    border-radius: 4px;
    background: var(--bg-panel);
    color: var(--text-primary);
}

#search:focus {
    outline: none;
}

#clear-search {
    display: none;
    position: absolute;
    right: 3px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
}

#clear-search.visible {
    display: flex;
}

#clear-search:hover {
    background: var(--bg-hover);
}

#favorites-filter-btn {
    width: 36px;
    padding: 0;
    font: inherit;
    font-size: 1rem;
    box-sizing: border-box;
    border: 1px solid var(--border-subtle);
    background: var(--bg-panel);
    color: var(--text-muted);
    cursor: pointer;
}

#favorites-filter-btn:hover {
    background: var(--bg-hover);
}

#favorites-filter-btn.active {
    color: #eab308;
}

#countries-wrap {
    position: relative;
}

#countries-btn {
    width: 36px;
    height: 100%;
    padding: 0;
    font: inherit;
    box-sizing: border-box;
    border: 1px solid var(--border-subtle);
    background: var(--bg-panel);
    color: var(--text-muted);
    cursor: pointer;
}

#countries-btn:hover,
#countries-btn.open {
    background: var(--bg-hover);
}

#countries-menu {
    position: absolute;
    z-index: 1000;
    right: 0;
    top: calc(100% + 4px);
    padding: 4px;
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

#countries-menu.hidden {
    display: none;
}

.country-option {
    min-width: 150px;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 0.9em;
    color: var(--text-primary);
    cursor: pointer;
    box-sizing: border-box;
    white-space: nowrap;
}

.country-option:hover {
    background: var(--bg-hover);
}

#sort-wrap {
    position: relative;
}

#sort-btn {
    width: 36px;
    height: 100%;
    padding: 0;
    font: inherit;
    box-sizing: border-box;
    border: 1px solid var(--border-subtle);
    background: var(--bg-panel);
    color: var(--text-muted);
    cursor: pointer;
}

#sort-btn:hover,
#sort-btn.open {
    background: var(--bg-hover);
}

#sort-menu {
    position: absolute;
    z-index: 1000;
    right: 0;
    top: calc(100% + 4px);
    padding: 4px;
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

#sort-menu.hidden {
    display: none;
}

.sort-option {
    min-width: 130px;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 0.9em;
    color: var(--text-primary);
    cursor: pointer;
    box-sizing: border-box;
}

.sort-option:hover {
    background: var(--bg-hover);
}

.sort-option.active {
    font-weight: bold;
}

.sort-option.disabled {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}

#list {
    flex: 1;
    min-height: 0;
    margin: 0;
    padding: 4px 8px;
    list-style: none;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#list li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 8px;
    border-radius: 4px;
    border: 1px solid transparent;
    cursor: pointer;
    /* We disable user select in the list to prevent double clicking from
     triggering select text */
    user-select: none;
    /* Without this, a real double-tap on mobile can get consumed by the
     browser's native double-tap-to-zoom gesture instead of firing our own
     dblclick handler. */
    touch-action: manipulation;
}

#list li .name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#list li .distance {
    /* Pins to the right edge regardless of how many items precede it -
     needed now that the favorite star is a 3rd row item, since
     justify-content: space-between only reads sensibly with exactly 2. */
    margin-left: auto;
    flex-shrink: 0;
    color: var(--text-muted-alt);
    font-size: 0.85em;
}

.list-favorite-btn {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.list-favorite-btn.active {
    color: #eab308;
}

#list li:hover {
    background: var(--bg-hover);
}

#list li.list-placeholder {
    cursor: default;
    text-align: center;
    color: var(--text-muted-alt);
    padding: 16px;
}

#list li.list-placeholder:hover {
    background: transparent;
}

#list li.selected {
    background: rgba(234, 88, 12, 0.15);
    border-color: #ea580c;
    font-weight: bold;
}

.placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 8px;
    color: var(--text-muted-alt);
    padding: 16px;
}

.placeholder p {
    margin: 0;
}

.placeholder-emoji {
    font-size: 2.5rem;
}