/*
 * Inqi chat foreground contrast.
 *
 * This stylesheet intentionally does not set bubble or page backgrounds: those
 * remain owned by the day/night theme and the login constellation theme.
 */

/* Logged-in chat: use a foreground chosen for each existing message surface. */
body.theme-dawn #InqiChat,
body.theme-dawn #InqiChat + .p-4,
body.theme-dawn #InqiChat ~ .userChat,
body.theme-dawn #InqiChat ~ .botChat {
    color: #422006 !important;
}

body.theme-day #InqiChat,
body.theme-day #InqiChat ~ .userChat,
body.theme-day #InqiChat ~ .botChat {
    color: #172554 !important;
}

/* The introductory copy is a sibling of the InqiChat surface in the template. */
body.theme-day #InqiChat + .p-4 {
    color: #ffffff !important;
}

body.theme-dusk #InqiChat,
body.theme-dusk #InqiChat + .p-4,
body.theme-dusk #InqiChat ~ .userChat,
body.theme-dusk #InqiChat ~ .botChat {
    color: #3f1d0f !important;
}

body.theme-night #InqiChat,
body.theme-night #InqiChat + .p-4,
body.theme-night #InqiChat ~ .userChat,
body.theme-night #InqiChat ~ .botChat {
    color: #f8fafc !important;
}

body.theme-dawn #InqiChat + .p-4 a {
    color: #9f1239 !important;
}

body.theme-day #InqiChat + .p-4 a,
body.theme-night #InqiChat + .p-4 a {
    color: #bfdbfe !important;
}

body.theme-dusk #InqiChat + .p-4 a {
    color: #9a3412 !important;
}

/* Utility text classes in live and restored messages otherwise beat inheritance. */
body.theme-dawn #InqiChat ~ :is(.userChat, .botChat) :is(.text-gray-500, .text-gray-600, .text-gray-700, .text-gray-800),
body.theme-dawn #InqiChat + .p-4 :is(.text-gray-500, .text-gray-600, .text-gray-700, .text-gray-800) {
    color: #422006 !important;
}

body.theme-day #InqiChat ~ :is(.userChat, .botChat) :is(.text-gray-500, .text-gray-600, .text-gray-700, .text-gray-800) {
    color: #172554 !important;
}

body.theme-day #InqiChat + .p-4 :is(.text-gray-500, .text-gray-600, .text-gray-700, .text-gray-800) {
    color: #ffffff !important;
}

body.theme-dusk #InqiChat ~ :is(.userChat, .botChat) :is(.text-gray-500, .text-gray-600, .text-gray-700, .text-gray-800),
body.theme-dusk #InqiChat + .p-4 :is(.text-gray-500, .text-gray-600, .text-gray-700, .text-gray-800) {
    color: #3f1d0f !important;
}

body.theme-night #InqiChat ~ :is(.userChat, .botChat) :is(.text-gray-500, .text-gray-600, .text-gray-700, .text-gray-800),
body.theme-night #InqiChat + .p-4 :is(.text-gray-500, .text-gray-600, .text-gray-700, .text-gray-800) {
    color: #f8fafc !important;
}

/* Loading text and links are distinct without losing contrast on the bubble. */
body.theme-dawn #InqiChat ~ :is(.userChat, .botChat) :is(a, .text-blue-600) {
    color: #9f1239 !important;
}

body.theme-day #InqiChat ~ :is(.userChat, .botChat) :is(a, .text-blue-600) {
    color: #1e40af !important;
}

body.theme-dusk #InqiChat ~ :is(.userChat, .botChat) :is(a, .text-blue-600) {
    color: #9a3412 !important;
}

body.theme-night #InqiChat ~ :is(.userChat, .botChat) :is(a, .text-blue-600) {
    color: #bfdbfe !important;
}

/* Markdown code has its own surface, so it must not inherit the bubble color. */
#InqiChat ~ :is(.userChat, .botChat) code:not(pre code) {
    color: #111827 !important;
}

body.theme-night #InqiChat ~ :is(.userChat, .botChat) code:not(pre code) {
    color: #f8fafc !important;
}

#InqiChat ~ :is(.userChat, .botChat) pre,
#InqiChat ~ :is(.userChat, .botChat) pre code {
    color: #ffffff !important;
}

/* MLA references keep a pale surface in dawn/day/dusk and a dark one at night. */
body:not(.theme-night) #InqiChat ~ :is(.userChat, .botChat) .myPrompt {
    color: #334155 !important;
}

body.theme-night #InqiChat ~ :is(.userChat, .botChat) .myPrompt {
    color: #f1f5f9 !important;
}

/* Error/success notices retain their existing pale red/green surfaces at night. */
#InqiChat ~ .bg-red-100 {
    color: #7f1d1d !important;
}

#InqiChat ~ .bg-green-100 {
    color: #14532d !important;
}

/* Logged-in editor and its label, including WebKit's independent text fill. */
body.theme-dawn #chat-input-area :is(span, textarea),
body.theme-day #chat-input-area :is(span, textarea),
body.theme-dusk #chat-input-area :is(span, textarea) {
    color: #111827 !important;
    -webkit-text-fill-color: #111827 !important;
    caret-color: #111827;
}

body.theme-night #chat-input-area textarea {
    color: #f8fafc !important;
    -webkit-text-fill-color: #f8fafc !important;
    caret-color: #f8fafc;
}

body.theme-night #chat-input-area span {
    color: #111827 !important;
    -webkit-text-fill-color: #111827 !important;
}

body.theme-dawn #userInput::placeholder,
body.theme-day #userInput::placeholder,
body.theme-dusk #userInput::placeholder {
    color: #4b5563 !important;
    -webkit-text-fill-color: #4b5563 !important;
    opacity: 1;
}

body.theme-night #userInput::placeholder {
    color: #cbd5e1 !important;
    -webkit-text-fill-color: #cbd5e1 !important;
    opacity: 1;
}

/*
 * Login demo: its assistant and user bubbles are dark translucent surfaces
 * supplied by login.html's constellation theme.
 */
#inqi-panel #demo-chat-messages .bg-purple-50,
#inqi-panel #demo-chat-messages .bg-blue-100 {
    color: #f1f5f9 !important;
}

#inqi-panel #demo-chat-messages :is(.bg-purple-50, .bg-blue-100)
    :is(p, li, h1, h2, h3, h4, h5, h6, blockquote, td, th) {
    color: #f1f5f9 !important;
}

#inqi-panel #demo-chat-messages :is(.bg-purple-50, .bg-blue-100) a {
    color: #bfdbfe !important;
}

/* Inline code remains pale; fenced code remains dark. */
#inqi-panel #demo-chat-messages :is(.bg-purple-50, .bg-blue-100) code:not(pre code) {
    color: #111827 !important;
}

#inqi-panel #demo-chat-messages :is(.bg-purple-50, .bg-blue-100) pre,
#inqi-panel #demo-chat-messages :is(.bg-purple-50, .bg-blue-100) pre code {
    color: #ffffff !important;
}

/* The citation panel has its own white surface inside the dark user bubble. */
#inqi-panel #demo-chat-messages .mla-reference {
    color: #334155 !important;
}

/* Keep the demo editor readable without changing its enable/disable behavior. */
#inqi-panel #demo-message-input {
    color: #1e293b !important;
    -webkit-text-fill-color: #1e293b !important;
    caret-color: #1e293b !important;
}

#inqi-panel #demo-message-input::placeholder {
    color: #64748b !important;
    -webkit-text-fill-color: #64748b !important;
    opacity: 1 !important;
}