#mkdChatLauncher {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #4169e1;
    color: #fff;
    font-size: 26px;
    text-align: center;
    line-height: 56px;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0,0,0,.3);
    z-index: 99999;
}

    #mkdChatLauncher:hover {
        color: #fff;
        text-decoration: none;
    }

/* The chat page wrapper fills the layout's content area (no extra centering/margins). */
#mkdChatPage {
    display: block;
}

/* In-page chat card: fills the available content width and height in normal document
   flow inside the site layout. No fixed positioning, so the on-screen keyboard simply
   scrolls the page. */
#mkdChatPanel {
    width: 100%;
    height: 78vh;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
}

    /* Keep padding/borders inside element widths so nothing overflows the card. */
    #mkdChatPanel *,
    #mkdChatPanel *::before,
    #mkdChatPanel *::after {
        box-sizing: border-box;
    }

#mkdChatHeader {
    background: #4169e1;
    color: #fff;
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 8px 8px 0 0;
    font-weight: bold;
}

#mkdChatMessages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px;
    font-size: 14px;
    background: #fafafa;
}

#mkdChatInputBar {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    border-top: 1px solid #eee;
    padding: 8px;
}

#mkdChatInput {
    flex: 1 1 auto;
    min-width: 0;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 6px;
    margin-right: 6px;
}

#mkdChatSend {
    flex: 0 0 auto;
    white-space: nowrap;
}

.mkd-msg {
    margin-bottom: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    max-width: 85%;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.mkd-user {
    background: #e1ecff;
    margin-left: auto;
    text-align: right;
}

.mkd-bot {
    background: #f1f1f1;
}

.mkd-sources {
    margin-top: 4px;
}

.mkd-sources a {
    display: inline-block;
    font-size: 12px;
    margin: 2px 4px 0 0;
    color: #4169e1;
    max-width: 100%;
    overflow-wrap: break-word;
    word-break: break-word;
}

.mkd-hidden {
    display: none !important;
}

/* Mobile: let the in-page chat card use the available height and stack the Send
   button below the textbox so it always fits a narrow screen. Capping with dvh keeps
   the panel within the visible viewport when the keyboard opens, so only the message
   list scrolls instead of the whole page extending. */
@media (max-width: 600px) {
    /* Break out of the centered, padded site container so the chat reaches both edges
       (removes the aliceblue gaps on the sides). */
    #mkdChatPage {
        width: 100vw;
        margin-left: calc(50% - 50vw);
        margin-right: calc(50% - 50vw);
    }

    #mkdChatPanel {
        height: 80vh;
        max-height: 80dvh;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    #mkdChatHeader {
        padding: 14px;
        font-size: 18px;
    }

    #mkdChatInputBar {
        flex-direction: column;
        align-items: stretch;
    }

    #mkdChatInput {
        margin-right: 0;
        margin-bottom: 8px;
    }

    #mkdChatSend {
        width: 100%;
    }
}
