.chat-stack {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-card {
    background: transparent;
    border: none;
    border-radius: 6px;
    padding: 4px 6px;
    position: relative;
    transition: background-color 0.15s ease;

    &.is-active {
        background-color: rgba(0, 123, 255, 0.10);
    }

    &:hover {
        background-color: rgba(0, 0, 0, 0.05);
    }

    &.is-active:hover {
        background-color: rgba(0, 123, 255, 0.14);
    }

    &.is-selected {
        background-color: #eef5ff;
    }
}

.chat-card-link {
    display: block;
    text-decoration: none;
    color: #222;
    min-width: 0;
}

.chat-card-number {
    font-size: 12px;
    font-weight: 600;
    color: #555;
}

.chat-card-prompt {
    font-size: 13px;
    line-height: 1.35;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.chat-card-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-card-row .chat-card-link {
    flex: 1;
    min-width: 0;
}

.chat-card-menu-wrap {
    position: relative;
    flex-shrink: 0;
}

.chat-card-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    background: transparent;
    border-radius: 4px;
    color: #777;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease, color 0.15s ease, background-color 0.15s ease;

    i {
        font-size: 14px;
    }

    &:hover {
        color: #222;
        background-color: rgba(0, 0, 0, 0.08);
    }
}

.chat-card:hover .chat-card-menu-btn,
.chat-card-menu-wrap:has(.chat-card-menu.open) .chat-card-menu-btn {
    opacity: 1;
}

.chat-card-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    min-width: 160px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
    padding: 4px;
    z-index: 20;
    display: none;
}

.chat-card-menu.open {
    display: flex;
    flex-direction: column;
}

.chat-card-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    font-size: 12px;
    color: #333;
    text-decoration: none;
    border-radius: 4px;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
    width: 100%;
    box-sizing: border-box;

    i {
        font-size: 12px;
    }

    &:hover {
        background-color: #f3f4f6;
    }
}

.chat-card-menu-item-danger {
    color: #dc2626;

    &:hover {
        background-color: rgba(220, 38, 38, 0.08);
    }
}

.chat-card-menu-form {
    margin: 0;
    width: 100%;
}

.chat-list-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 28px;
    /* Pin the heading + bulk-action row to the top of the scrollable
       sidebar so it stays accessible when the chat list is long. The
       opaque background masks cards scrolling underneath; the explicit
       z-index lifts the toolbar above sibling cards in stacking. The
       negative top/side margins extend the toolbar across the host
       sidebar's 8px padding so scrolling cards can't peek through the
       gap above it; equal padding keeps the toolbar's content in its
       natural place. */
    position: sticky;
    top: 0;
    background-color: #ffffff;
    z-index: 2;
    margin: -8px -8px 6px;
    padding: 8px 8px 0;

    h2 {
        margin: 0;
        font-size: 14px;
        line-height: 1.2;
    }
}

.chat-list-select-all {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    accent-color: #007bff;
    flex-shrink: 0;
}

.chat-list-heading {
    flex: 1;
    min-width: 0;
}

.chat-list-bar {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

.chat-list-toolbar .hidden {
    display: none;
}

.chat-list-bar-count {
    font-size: 12px;
    color: #555;
    white-space: nowrap;
}

.chat-list-bar-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-list-bar-download,
.chat-list-bar-delete {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    color: #555;
    transition: color 0.15s ease, background-color 0.15s ease;

    i {
        font-size: 14px;
    }
}

.chat-list-bar-download:hover {
    color: #007bff;
    background-color: rgba(0, 123, 255, 0.1);
}

.chat-list-bar-delete:hover {
    color: #dc2626;
    background-color: rgba(220, 38, 38, 0.1);
}

.chat-card-checkbox {
    width: 14px;
    height: 14px;
    margin: 0;
    cursor: pointer;
    accent-color: #007bff;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.chat-card:hover .chat-card-checkbox,
.chat-card-checkbox:checked {
    opacity: 1;
}

.chat-card-title-input {
    font-size: 13px;
    line-height: 1.35;
    width: 100%;
    padding: 2px 4px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    outline: none;

    &:focus {
        border-color: #007bff;
        box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
    }
}
