@keyframes chatFadeIn {
    from { opacity: 0; transform: translateY(6px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.chat-message-bubble {
    animation: chatFadeIn .28s ease-out both;
}

.prose-chat {
    color: currentColor;
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.prose-chat :where(h1, h2, h3) {
    color: inherit;
    font-weight: 600;
    margin-top: 1em;
    margin-bottom: 0.5em;
}
.prose-chat :where(h1) { font-size: 1.25em; }
.prose-chat :where(h2) { font-size: 1.1em; }
.prose-chat :where(h3) { font-size: 1em; }

.prose-chat :where(p) {
    margin-top: 0.75em;
    margin-bottom: 0.75em;
}

.prose-chat :where(a) {
    color: inherit;
    text-decoration: underline;
    font-weight: 500;
    cursor: pointer;
}

.prose-chat :where(ul, ol) {
    margin-top: 0.75em;
    margin-bottom: 0.75em;
    padding-left: 1.5em;
}
.prose-chat :where(ul) { list-style-type: disc; }
.prose-chat :where(ol) { list-style-type: decimal; }

.prose-chat :where(li) {
    margin-top: 0.25em;
}



/* Collapsed table + rounded overlay */
.prose-chat :where(table) {
    position: relative;
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
    font-size: 0.9em;
}

/* Base grid */
.prose-chat :where(th, td) {
    border: 1px solid currentColor;
    opacity: 0.6;
    padding: 0.3rem 0.5rem;
    text-align: left;
}

/* Remove ONLY the outer perimeter borders */
.prose-chat :where(thead:first-child tr:first-child > *),
.prose-chat :where(tbody:first-child tr:first-child > *),
.prose-chat :where(tfoot:first-child tr:first-child > *) { border-top: 0; }

.prose-chat :where(tfoot:last-child tr:last-child > *),
.prose-chat :where(tbody:last-child tr:last-child > *) { border-bottom: 0; }

.prose-chat :where(tr > *:first-child) { border-left: 0; }
.prose-chat :where(tr > *:last-child)  { border-right: 0; }

/* ❗Prevent double lines between sections (single divider only) */
.prose-chat :where(thead + tbody tr:first-child > *) { border-top: 0; }  /* header → body */
.prose-chat :where(tbody + tbody tr:first-child > *) { border-top: 0; }  /* multiple bodies */
.prose-chat :where(tbody + tfoot tr:first-child > *) { border-top: 0; }  /* body → footer */

/* Rounded outer border overlay */
.prose-chat :where(table)::before {
    content: "";
    position: absolute;
    inset: 0;
    border: 1px solid currentColor;   /* visible outer border */
    border-radius: 0.4rem;           /* subtle rounding (~4px) */
    pointer-events: none;
}

/* Header styling */
.prose-chat :where(thead) {
    font-weight: bold;
    background-color: rgba(0,0,0,0.1);
}




.prose-chat :where(code) {
    background-color: rgba(0, 0, 0, 0.1);
    padding: 0.1em 0.3em;
    border-radius: 4px;
    font-size: 0.9em;
}

.prose-chat :where(pre) {
    background-color: rgba(0, 0, 0, 0.1);
    padding: 0.5em;
    border-radius: 6px;
    overflow-x: auto;
}

.prose-chat :where(pre code) {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    font-size: 1em;
}

.prose-chat > :first-child {
    margin-top: 0;
}

.prose-chat > :last-child {
    margin-bottom: 0;
}

.prose-chat :where(details) {
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    margin-top: 1em;
    margin-bottom: 1em;
    overflow: hidden;
}

.prose-chat :where(summary) {
    cursor: pointer;
    padding: 0.5em 1em;
    font-weight: 600;
    background-color: rgba(0, 0, 0, 0.05);
}

.prose-chat :where(details[open] > summary) {
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.prose-chat :where(details > div) {
    padding: 1em;
}

.prose-chat :where(input) {
    padding: 0.25rem;
    border: 1px solid #d1d5db;
    border-radius: 0.25rem;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
}
.prose-chat :where(input:focus) {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.4); /* thinner focus ring */
}

.prose-chat :where(button) {
    background: #3b82f6;
    color: #fff;
    padding: 0.25rem 0.5rem;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: background 0.2s;
}
.prose-chat :where(button:hover) {
    background: #2563eb;
}
.prose-chat :where(button:focus) {
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5), 0 0 0 4px #fff;
}

/* select */
.prose-chat :where(select) {
    padding: 0.25rem 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.25rem;
    background: #fff;
    color: #111827;
    font-size: 0.875rem;
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, #6b7280 50%), linear-gradient(135deg, #6b7280 50%, transparent 50%);
    background-position: calc(100% - 0.75rem) center, calc(100% - 0.5rem) center;
    background-size: 0.5rem 0.5rem;
    background-repeat: no-repeat;
    cursor: pointer;
}
.prose-chat :where(select:focus) {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4);
}

/* checkbox */
.prose-chat :where(input[type="checkbox"]) {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    width: 32px;
    height: 16px;
    margin-right: 0.4rem;
    background: #d1d5db;
    border-radius: 16px;
    outline: none;
    cursor: pointer;
    vertical-align: middle;
    transition: background 0.2s;
}
.prose-chat :where(input[type="checkbox"])::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 10px;
    height: 10px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.prose-chat :where(input[type="checkbox"]:checked) {
    background: #3b82f6;
}
.prose-chat :where(input[type="checkbox"]:checked)::before {
    transform: translateX(16px);
}
.prose-chat :where(input[type="checkbox"]:focus) {
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4);
}

/* textarea */
.prose-chat :where(textarea) {
    width:100%;
    min-height:4rem;
    padding:0.25rem 0.5rem;
    border:1px solid #d1d5db;
    border-radius:0.25rem;
    background:#fff;
    color:#111827;
    font-size:0.875rem;
    resize:vertical;
    outline:none;
    transition:border-color 0.2s, box-shadow 0.2s;
}
.prose-chat :where(textarea:focus) {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4);
}