.memori-chat--wrapper {
    position: relative;
    display: flex;
    width: 100%;
    height: 100%;
    flex-direction: column;
}

@media (max-width: 768px) {
    .memori-chat--wrapper.chat-focused {
        padding-bottom: 0;
    }
}

.memori-chat--history {
    position: relative;
    overflow: hidden;
    width: 100%;
    height: calc(100% - 50px);
    flex: 1;
    padding: calc(var(--memori-inner-content-pad) / 4) calc(var(--memori-inner-content-pad) / 2);
    border-radius: 10px;
    margin: 1rem 0;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    background-color: var(--memori-inner-bg);
}

.memori-chat--history.memori-chat--history-touch {
    height: 80% !important;
    padding: 0;
}

/* Adjust chat history when textarea is expanded */
.memori-chat-wrapper--expanded .memori-chat--history {
    margin-bottom: 0.5rem;
}

.memori-chat--content {
    position: relative;
    display: flex;
    height: 100%;
    flex: 1;
    flex-direction: column;
    padding: 2rem 10px;
    /* mask-image: linear-gradient(transparent, black 5%, black 95%, transparent 100%); */
    overflow-y: auto;
    scroll-behavior: smooth;
}

.memori-chat--content.memori-chat--content-touch {
    padding: 0;
}

/* Ensure smooth scrolling on mobile */
@media (max-width: 768px) {
    .memori-chat--content {
        padding: 1rem 5px;
    }
}

.memori-chat--cover {
    position: relative;
    width: 100%;
    padding-top: 31.25%;
    margin-top: 10px;
    margin-bottom: 10px;
    background-position: center;
    background-size: cover;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

/* Hide the initial divider when there is a cover (works even with MediaWidget before first ChatBubble) */
.memori-chat--cover ~ .memori-chat--bubble-initial {
    display: none;
}

.memori-chat--timestamp {
    display: inline-block;
    padding: 0 3.5rem;
    margin-bottom: 0.5em;
    color: #969696;
    font-size: 0.8em;
}

.memori-chat--timestamp.text-left {
    text-align: left;
}

.memori-chat--timestamp.text-right {
    text-align: right;
}

.memori-chat--context-vars {
    padding: 0 3.5rem;
    margin-bottom: 0.5em;
}

.memori-chat--context-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 5px;
    margin-right: 0.5rem;
    box-shadow: 0 0 0.25rem var(--memori-primary);
    color: var(--text-color, #333);
    font-size: 0.75rem;
}

.memori-chat--context-tag:focus-within {
    border: 1px solid var(--memori-primary);
    box-shadow: none;
}

.memori-chat--context-tag.memori-chat--context-tag-canceled {
    opacity: 0.7;
    text-decoration: line-through 1.5px;
}

.memori-chat--context-tag-text {
    display: inline-block;
    overflow: hidden;
    max-width: 200px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.memori-chat--context-tag+.memori-chat--context-tag {
    margin-top: 0.5rem;
}

.memori-chat--known-tags {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.memori-chat--known-tag {
    margin-right: 0.5rem;
}

/* Drag and drop overlay */
.memori-chat--drag-overlay {
    position: absolute;
    z-index: 1000;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    backdrop-filter: blur(4px);
    background-color: rgba(0, 0, 0, 0.7);
    pointer-events: none;
}

.memori-chat--drag-overlay-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    color: #fff;
    opacity: 0.9;
}

.memori-chat--drag-overlay-text {
    padding: 0 2rem;
    color: #ffffff;
    font-size: 1.2rem;
    font-weight: 500;
    text-align: center;
}

.memori-chat--llm-usage {
    margin-top: 0.625rem;
}

.memori-chat--usage-inside-bubble {
    margin-top: 0.25rem;
}

.memori-chat--llm-usage-hr {
    border: 0;
    border-top: 1px solid rgba(148, 163, 184, 0.35);
    margin: 0 0 0.5rem;
}

.memori-chat--llm-usage-hint {
    margin: 0 0 0.5rem;
    color: #64748b;
    font-size: 0.75rem;
}

.memori-chat--llm-usage-badges {
    display: flex;
    flex-wrap: wrap;
    margin-top: 0.5rem;
    gap: 0.375rem;
}

.memori-chat--usage-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.5rem;
    border: 1px solid #d4d8dd;
    border-radius: 999px;
    background: #fff;
    color: #1f2937;
    cursor: pointer;
    font-size: 0.75rem;
    gap: 0.25rem;
    line-height: 1;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.memori-chat--usage-badge:hover {
    border-color: var(--memori-primary,#1890ff);
    background-color: #f8fafc;
    color: var(--memori-primary,#1890ff);
}

.memori-chat--usage-badge:focus-visible {
    outline: 2px solid var(--memori-primary);
    outline-offset: 2px;
}

.memori-chat--usage-badge-value {
    font-weight: 600;
}

.memori-chat--usage-modal .memori-modal--panel {
    min-width: 20rem;
    max-width: 30rem;
}

.memori-chat--usage-details {
    margin: 0;
}

.memori-chat--usage-details div {
    display: flex;
    justify-content: space-between;
    padding: 0.375rem 0;
    gap: 1rem;
}

.memori-chat--usage-details dt {
    color: #64748b;
    font-size: 0.875rem;
}

.memori-chat--usage-details dd {
    margin: 0;
    color: #111827;
    font-size: 0.875rem;
    font-weight: 600;
    text-align: right;
}

.memori-chat--usage-educational-content {
    display: flex;
    flex-direction: column;
    padding-top: 0.25rem;
    gap: 0.5rem;
}

.memori-chat--usage-metric-value {
    display: block;
    margin: 0;
    color: #111827;
    font-size: 1.125rem;
}

.memori-chat--usage-comparable {
    margin: 0;
    color: #374151;
    font-size: 0.875rem;
}

.memori-chat--usage-educational-content p {
    margin: 0;
}