/* Stable spacing for date-grouped saved chats. Loaded after legacy list rules. */
#chatsListGrid {
    display: flex !important;
    flex-direction: column !important;
    gap: 0 !important;
}

#chatsListGrid .chat-date-group {
    display: flex !important;
    flex-direction: column !important;
    gap: 14px !important;
    min-width: 0;
    margin: 0 !important;
}

#chatsListGrid .chat-date-group + .chat-date-group {
    margin-top: 10px !important;
}

#chatsListGrid .chat-date-divider {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    min-height: 24px !important;
    margin: 0 8px 4px !important;
    padding: 0 2px !important;
    box-sizing: border-box;
    color: var(--text-secondary, #a6a6a6) !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    letter-spacing: 0.02em !important;
    line-height: 1 !important;
    opacity: 0.9;
}

#chatsListGrid .chat-date-group:first-child .chat-date-divider {
    margin-top: 0 !important;
}

#chatsListGrid .chat-date-divider::before,
#chatsListGrid .chat-date-divider::after {
    content: "";
    flex: 1 1 auto;
    height: 1px;
    background: rgba(255, 255, 255, 0.28) !important;
}

#chatsListGrid .chat-date-divider span {
    flex: 0 0 auto;
    white-space: nowrap;
}

#chatsListGrid .chat-date-group > .project-chat-card {
    width: 100% !important;
    min-height: 64px !important;
    margin: 0 !important;
    box-sizing: border-box;
}

#chatsListGrid .chat-date-group > .project-chat-card + .project-chat-card {
    margin-top: 0 !important;
}

body.light-mode #chatsListGrid .chat-date-divider {
    color: var(--text-secondary, #5d6470) !important;
}

body.light-mode #chatsListGrid .chat-date-divider::before,
body.light-mode #chatsListGrid .chat-date-divider::after {
    background: rgba(15, 23, 42, 0.24) !important;
}

/* Keep project rows readable too, without changing their hierarchy. */
#chatsListGrid > .project-folder-header {
    margin-bottom: 14px !important;
}

#chatsListGrid > .project-nested-chats:not(.collapsed) {
    margin-bottom: 14px !important;
    row-gap: 14px !important;
}

/* Project chats use the same readable card rhythm and day dividers. */
#chatsListGrid > .project-nested-chats .chat-date-group {
    gap: 14px !important;
}

#chatsListGrid > .project-nested-chats .chat-date-group + .chat-date-group {
    margin-top: 10px !important;
}

#chatsListGrid > .project-nested-chats .project-chat-card {
    min-height: 64px !important;
    margin: 0 !important;
}

@media (max-width: 720px) {
    #chatsListGrid .chat-date-group + .chat-date-group {
        margin-top: 8px !important;
    }

    #chatsListGrid > .project-nested-chats .chat-date-group + .chat-date-group {
        margin-top: 8px !important;
    }
}

/* Chat rows stay readable at rest. The surface must not appear only on hover,
   and the list should feel like a compact history rather than a stack of
   oversized cards. */
.chat-secondary-sidebar .chat-history-list {
    gap: 3px !important;
    margin-top: 6px !important;
}

.chat-secondary-sidebar .history-item {
    min-height: 44px !important;
    padding: 7px 40px 7px 10px !important;
    border: 1px solid transparent !important;
    border-radius: 10px !important;
    background: var(--logicum-surface-raised, #373531) !important;
    box-shadow: none !important;
}

.chat-secondary-sidebar .history-item:hover,
.chat-secondary-sidebar .history-item:focus-visible {
    background: var(--logicum-surface-hover, #3b3935) !important;
    border-color: var(--logicum-border, #48443f) !important;
    outline: none;
}

.chat-secondary-sidebar .history-item.active {
    background: color-mix(in srgb, var(--logicum-orange, #d9703f) 10%, var(--logicum-surface-raised, #373531)) !important;
    border-color: color-mix(in srgb, var(--logicum-orange, #d9703f) 30%, var(--logicum-border, #48443f)) !important;
}

.chat-secondary-sidebar .history-preview {
    margin-top: 2px;
}
