[data-saved-search-nav][hidden],
.saved-search-panel[hidden] {
    display: none !important;
}

/* Results row: summary text | save + view toggle. It stays one row at any width:
   the summary wraps (up to two lines) inside its own column, and on a narrow row
   the save button drops its label (see the container query below). */
.list-gal-buttons:has(> .listing-results-actions) {
    container: results-toolbar / inline-size;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
}

.list-gal-buttons:has(> .listing-results-actions) > .results-summary-text.results-summary-text {
    flex: 1 1 auto;
    min-width: 0;
    margin-top: 0;
    margin-bottom: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
}

.listing-results-actions {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    margin-inline-start: auto;
    position: relative;
}

.listing-results-actions .view-toggle {
    margin-right: 0;
}

.save-search-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 25px;
    padding: 4px 12px;
    border: 1px solid #acc8e2;
    border-radius: 999px;
    background: #fff;
    color: #174c79;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.save-search-button:not([aria-disabled="true"]):hover {
    background: #e0eefb;
    border-color: #81add6;
}

.save-search-button.is-saved {
    background: #fff;
    border-color: #81add6;
}

.save-search-button[aria-disabled="true"] {
    cursor: default;
}

.save-search-button:focus-visible,
.saved-search-panel a:focus-visible {
    outline: 2px solid #0e5c98;
    outline-offset: 2px;
}

.save-search-status {
    position: absolute;
    z-index: 2;
    top: calc(100% + 4px);
    right: 0;
    width: max-content;
    max-width: min(18rem, calc(100vw - 32px));
    padding: 6px 9px;
    border: 1px solid #e3c5c5;
    border-radius: 6px;
    background: #fff8f8;
    color: #802727;
    font-size: 12px;
}

.save-search-status:empty {
    opacity: 0;
    pointer-events: none;
}

/* Repeat-search popover, anchored under the save pill. */
.list-gal-buttons:has(.save-search-nudge:not([hidden])) {
    position: relative;
    z-index: 40;
}

.save-search-nudge {
    --action-nudge-arrow-right: var(--save-search-nudge-arrow-right, 24px);
}

.save-search-nudge__live {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.saved-search-panel {
    padding: 10px 12px;
    text-align: left;
}

.saved-search-panel--standalone {
    position: absolute;
    top: 100%;
    inset-inline: 0;
    z-index: 5;
    border: 1px solid #d5d9de;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.search-row:has(.saved-search-panel--standalone:not([hidden])) {
    z-index: 5;
}

.saved-search-panel__heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
    color: #263541;
    font-size: 14px;
    font-weight: 600;
}

.saved-search-panel__heading a {
    color: #005789;
}

.saved-search-panel__links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Cap the item, not the link: a capped link inside an uncapped item leaves a gap. */
.saved-search-panel__links li {
    flex: 0 1 auto;
    min-width: 0;
    max-width: min(100%, 22rem);
}

.saved-search-panel__links a {
    display: block;
    max-width: 100%;
    box-sizing: border-box;
    padding: 5px 9px;
    overflow: hidden;
    border: 1px solid #c7d9e9;
    border-radius: 999px;
    background: #f6faff;
    color: #174c79;
    font-size: 13px;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.saved-search-panel__links a:hover {
    background: #e9f3fd;
    text-decoration: underline;
}

.saved-search-list {
    margin: 0;
    padding: 10px clamp(10px, 2vw, 16px) 0;
    list-style: none;
}

.saved-search-list .saved-search-list__entry {
    box-sizing: border-box;
    width: 100%;
    height: auto;
    margin: 0 0 10px;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    background: #fff;
}

.saved-search-list__copy {
    flex: 1 1 12rem;
    min-width: 0;
    padding: 12px 14px;
    border-radius: inherit;
    color: inherit;
    text-decoration: none;
    overflow-wrap: anywhere;
}

.saved-search-list__copy:focus-visible,
.saved-search-list__entry button:focus-visible {
    outline: 2px solid #0e5c98;
    outline-offset: 2px;
}

.saved-search-list__copy p {
    margin: 4px 0 0;
    color: #515b65;
    font-size: 14px;
}

.saved-search-list__title {
    color: #064f81;
    font-weight: 650;
}

.saved-search-list__copy:hover .saved-search-list__title {
    text-decoration: underline;
}

.saved-search-list__entry form {
    margin: 8px 14px 8px auto;
}

.saved-search-list__entry button {
    padding: 6px 10px;
    border: 1px solid #d5d9de;
    border-radius: 999px;
    background: #fff;
    color: #374151;
    cursor: pointer;
}

.saved-search-list__entry button:hover {
    background: #f4f6f8;
}

.saved-search-list__pagination {
    display: flex;
    gap: 12px;
    align-items: baseline;
    margin: 12px 0;
}

.saved-search-resume {
    max-width: 30rem;
    margin: 8vh auto;
    padding: 20px;
    font: 16px system-ui, sans-serif;
}

/* Narrow results row (phones, and the list pane beside a map): icon-only save button.
   The label stays in the accessibility tree; the title attribute gives a tooltip. */
@container results-toolbar (max-width: 560px) {
    .save-search-button {
        width: 28px;
        min-height: 28px;
        padding: 0;
        flex: 0 0 auto;
    }

    .save-search-button__label {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
        border: 0;
    }
}
