/* Public favourites panel and checkbox controls. */
.favorites-box {
    position: sticky;
    top: 0;
    z-index: 9997;
    display: flex;
    flex-direction: column;
    max-height: 220px;
    max-height: clamp(205px, 26vh, 220px);
    margin: 10px 0;
    padding: 10px;
    border: var(--border-panel);
    background: #fffdf2;
    font-size: 14px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
}

.favorites-header {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 6px;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid #e4dfbf;
}

.favorites-title {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-right: auto;
    white-space: nowrap;
}

.favorites-title strong {
    color: #333;
}

.favorites-toggle-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 68px;
    min-height: 32px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #555;
    cursor: pointer;
    font: inherit;
    line-height: 1;
}

.favorites-toggle-button:disabled {
    color: #999;
    cursor: default;
}

.favorites-toggle-button:not(:disabled):hover {
    color: #333;
}

.favorites-toggle-button:focus-visible {
    outline: 1px dotted #777;
    outline-offset: 2px;
}

.favorites-count {
    color: #666;
    font-size: 13px;
}

.favorites-toggle-label {
    color: inherit;
    font-size: var(--font-size-control);
    line-height: 18px;
    text-align: right;
    white-space: nowrap;
}

.favorites-actions {
    display: flex;
    gap: 5px;
}

.favorites-action-menu {
    position: relative;
}

.favorites-menu-button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.favorites-header-action-button {
    justify-content: center;
    width: 80px;
    height: 32px;
    white-space: nowrap;
}

.favorites-menu-arrow {
    font-size: 9px;
    line-height: 1;
}

.favorites-actions-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 2;
    min-width: 88px;
    padding: 4px;
    border: 1px solid #999;
    background: #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.18);
}

.favorites-actions-menu[hidden] {
    display: none;
}

.favorites-actions-menu button {
    display: block;
    width: 100%;
    padding: 7px 8px;
    border: 0;
    text-align: left;
    white-space: nowrap;
}

.favorites-actions-menu button + button {
    border-top: 1px solid #ddd;
}

.favorites-actions-menu .favorites-mobile-only {
    display: none;
}

.favorites-panel {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.favorites-box.is-collapsed .favorites-header {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: 0;
}

.favorites-box.is-collapsed .favorites-panel {
    display: none;
}

.favorites-actions button,
.favorite-remove {
    padding: 3px 8px;
    border: 1px solid #999;
    background: #fff;
    color: #333;
    cursor: pointer;
    font-size: var(--font-size-control);
}

.favorites-actions button:hover,
.favorite-remove:hover {
    background: #f0f0f0;
}

.favorites-actions button:disabled {
    color: #aaa;
    cursor: default;
    background: #f5f5f5;
}

.favorites-list {
    margin: 0 0 0 20px;
    padding-left: 20px;
}

.favorites-list li {
    margin: 2px 0;
    word-break: break-word;
    overflow-wrap: break-word;
}

.favorites-list a {
    color: red;
}

.favorite-remove {
    margin-left: 6px;
}

.favorites-empty {
    margin: 0;
    color: #777;
}

.favorite-checkbox {
    width: 17px;
    height: 17px;
    margin: 0 5px 0 0;
    cursor: pointer;
    vertical-align: -2px;
}

.favorite-checkbox-hitbox {
    cursor: pointer;
}

.favorite-checkbox:focus {
    outline: 1px dotted #666;
}

@media screen and (max-width: 768px) {
    .favorites-box {
        padding: 6px 8px;
    }

    .favorites-header {
        flex-wrap: wrap;
    }

    .favorites-toggle-button {
        min-height: 36px;
    }
}

@media screen and (max-width: 480px) {
    .favorites-header {
        gap: 4px;
        flex-wrap: nowrap;
    }

    .favorites-title {
        gap: 3px;
        font-size: 13px;
    }

    .favorites-toggle-button {
        min-width: 36px;
        width: 36px;
        height: 36px;
        min-height: 36px;
    }

    .favorites-toggle-label {
        font-size: 0;
        line-height: 1;
    }

    .favorites-toggle-button[aria-expanded="true"] .favorites-toggle-label::before {
        content: "▲";
        font-size: 14px;
    }

    .favorites-toggle-button[aria-expanded="false"] .favorites-toggle-label::before {
        content: "▼";
        font-size: 14px;
    }

    .favorites-toggle-button:disabled .favorites-toggle-label::before {
        content: "—";
    }

    .favorites-actions button {
        min-height: 36px;
        padding: 5px 8px;
    }

    .favorites-actions .favorites-header-action-button {
        width: 70px;
        height: 36px;
        padding-right: 4px;
        padding-left: 4px;
        white-space: nowrap;
    }

    .favorite-remove {
        min-width: 44px;
        min-height: 32px;
        padding: 4px 8px;
    }

    .favorites-actions-menu .favorites-desktop-only {
        display: none;
    }

    .favorites-actions-menu .favorites-mobile-only {
        display: block;
    }

    .favorite-checkbox-hitbox {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        margin-right: 1px;
        vertical-align: middle;
    }

    .favorite-checkbox {
        width: 20px;
        height: 20px;
        margin: 0;
        vertical-align: middle;
    }
}
