.history-stack {
    position: relative;
    display: flex;
    flex-direction: column;
    padding-left: 32px; /* space for arrows */
    margin-top: 20px;
}

.history-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 8px 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    position: relative;
    z-index: 1;
    margin-bottom: 16px;
    transition:
            box-shadow 0.15s ease,
            transform 0.15s ease;

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

    &:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
        transform: translateY(-2px);
    }

    &:last-child {
        margin-bottom: 0;
    }

    &:has(+ .history-straight-arrow) {
        margin-bottom: 0;
    }
}

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

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

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

.history-card-delete-form {
    margin: 0;
    display: flex;
    align-items: center;
}

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

    i {
        font-size: 12px;
    }

    &:hover {
        color: #dc2626;
        background-color: rgba(220, 38, 38, 0.1);
    }
}

.history-card:hover .history-card-delete {
    opacity: 1;
}

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

.history-card-prompt {
    font-size: 12px;
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.history-card-platform-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
    flex-shrink: 0;
    padding: 2px 6px;
    border-radius: 4px;
    min-width: 28px;
    text-align: center;

    &[data-platform="openai"] { color: #10a37f; background: rgba(16, 163, 127, 0.1); }
    &[data-platform="anthropic"] { color: #c4956e; background: rgba(212, 162, 127, 0.12); }
    &[data-platform="google"] { color: #4285f4; background: rgba(66, 133, 244, 0.1); }
    &[data-platform="ollama"] { color: #555; background: rgba(0, 0, 0, 0.06); }
}

.history-arrows {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
    z-index: 0;
}

.history-straight-arrow {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 16px;
    margin: 0;
    font-size: 16px;
    font-weight: bold;
    color: #555;
    line-height: 1;
}
