#search-bar {
    display: flex;
    gap: 4px;
    margin: 8px 0 4px 0;
    width: 100%;
    max-width: 600px;
}

#search-input-wrapper {
    position: relative;
    flex: 2;
    display: flex;
    align-items: center;
    min-width: 50%;
}

#search-input {
    width: 100%;
    font-family: inherit;
    font-size: inherit;
    padding: 3px 24px 3px 6px;
    background: inherit;
    color: inherit;
    border: 1px solid var(--border);
    box-sizing: border-box;
}

#search-clear {
    position: absolute;
    right: 5px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.8em;
    padding: 0;
    line-height: 1;
    color: inherit;
    opacity: 0;
    pointer-events: none;
}

#search-input:not(:placeholder-shown) ~ #search-clear {
    opacity: 0.4;
    pointer-events: auto;
}

#search-clear:hover {
    opacity: 1;
}

#engine-select {
    font-family: inherit;
    font-size: inherit;
    padding: 3px 4px;
    background: inherit;
    color: inherit;
    border: 1px solid var(--border);
    cursor: pointer;
}

#search-bar > button {
    font-family: inherit;
    font-size: inherit;
    padding: 3px 10px;
    background: inherit;
    color: inherit;
    border: 1px solid var(--border);
    cursor: pointer;
    white-space: nowrap;
    flex: 1;
}

#search-bar > button:hover,
#engine-select:hover {
    background: var(--border);
    color: #fff;
}

#site-results {
    border: 1px solid var(--border);
    display: none;
    margin-bottom: 6px;
    width: 100%;
    max-width: 600px;
    box-sizing: border-box;
}

#site-results a {
    display: block;
    padding: 3px 6px;
    text-decoration: none;
    border-bottom: 1px solid var(--border);
    font-size: 0.9em;
}
#site-results a.sr-recent {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block; /* Ensures the ellipsis calculation works properly */
}
#site-results a:last-child { border-bottom: none; }
#site-results a:hover { background: var(--border); color: var(--border); }
#site-results .sr-label {
    padding: 2px 6px;
    font-size: 0.75em;
    opacity: 0.6;
    border-bottom: 1px solid var(--border);
}
#site-results .sr-clear {
    opacity: 0.45;
    font-size: 0.8em;
    border-top: 1px solid var(--border);
    border-bottom: none;
}
#site-results .sr-clear:hover {
    opacity: 1;
    background: var(--border);
    color: var(--border);
}

@media (max-width: 600px) {
    #search-bar {
        max-width: 100%;
        flex-wrap: wrap;
    }
    #engine-select {
        flex: 1;
    }
    #search-bar button {
        flex: 1;
    }
}

/* ── Favorites bar ── */
#favorites-bar {
    width: 100%;
    max-width: 600px;
    margin-bottom: 4px;
    font-size: 0.9em;
}
#favorites-bar details summary {
    cursor: pointer;
    padding: 2px 4px;
    list-style: none;
    user-select: none;
    opacity: 0.7;
}
#favorites-bar details summary::-webkit-details-marker { display: none; }
#favorites-bar details[open] summary { opacity: 1; }
#favorites-list {
    border: 1px solid var(--border);
    margin-top: 2px;
}
.fav-item {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
}
.fav-item:last-child { border-bottom: none; }
.fav-item a {
    flex: 1;
    padding: 3px 6px;
    text-decoration: none;
    font-size: 0.9em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.fav-item a:hover { text-decoration: underline; }
.fav-remove {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 6px;
    color: inherit;
    opacity: 0.4;
    font-size: 0.9em;
    flex-shrink: 0;
}
.fav-remove:hover { opacity: 1; }

/* ── Stars in site results ── */
.sr-item {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
}
.sr-item:last-child { border-bottom: none; }
.sr-item > a {
    flex: 1;
    padding: 3px 6px;
    text-decoration: none;
    font-size: 0.9em;
    border-bottom: none !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sr-item:hover { background: var(--border); }
.sr-item:hover > a { color: #fff; }
.sr-star {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 6px;
    color: inherit;
    opacity: 0.3;
    font-size: 0.9em;
    flex-shrink: 0;
    line-height: 1;
}
.sr-star:hover,
.sr-star.starred { opacity: 1; }

/* ── Sidebar (wide screens only) ── */
#favorites-sidebar {
    display: none;
    position: fixed;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    flex-direction: column;
    gap: 3px;
    z-index: 50;
}
@media (min-width: 900px) {
    #favorites-sidebar { display: flex; }
}
.fav-icon {
    width: 22px;
    height: 22px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-sizing: border-box;
}
.fav-icon img { width: 16px; height: 16px; display: block; }
