#chat-ui-container {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr auto;
    grid-template-areas:
        "bot-bubble"
        "user-bubble"
        "spacer"
        "chat-input-controls";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 20px;
    box-sizing: border-box;
    opacity: 0;
    align-content: start;
    gap: 20px;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out;
}
#chat-ui-container.visible {
    opacity: 1;
    pointer-events: auto;
}
.chat-bubble {
    position: absolute; 
    background-color: #ffffff;
    border: 1px solid #000;
    border-radius: 8px;
    padding: 15px 20px;
    font-family: Arial, sans-serif;
    max-width: 280px;
    min-width: 100px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    opacity: 0;
    transform: scale(0.95) translateY(10px);
    transition: opacity 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 1001;
    pointer-events: none;
}
.chat-bubble.visible {
    opacity: 1;
    transform: scale(1) translateY(0);
}
.bot-bubble {
    grid-area: bot-bubble;
    align-self: start;
    justify-self: start;
    margin-top: 0px;
}
.user-bubble {
    grid-area: user-bubble;
    align-self: start;
    justify-self: end;
    margin-top: 110px;

    background-color: #f0f0f0;
}

.bot-bubble::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 30px;
    width: 0;
    height: 0;
    border: 10px solid transparent;
    border-top-color: #ffffff;
    border-bottom: 0;
    filter: drop-shadow(0 2px 1px rgba(0,0,0,0.1));
}
.chat-bubble-name-tag {
    position: absolute;
    top: -15px;
    left: 20px;
    background-color: #00aaff;
    color: white;
    padding: 4px 12px;
    font-weight: bold;
    border: 1px solid #000;
    border-radius: 5px;
    font-size: 14px;
}
.bot-bubble .chat-bubble-name-tag {
    background-color: #28a745; 
}
.user-bubble .chat-bubble-name-tag {
    background-color: #007bff; 
}
.chat-bubble-content {
    margin-top: 10px;
    color: #000;
    font-size: 16px;
    line-height: 1.5;
}
.chat-bubble-content p {
    margin: 0;
}
/* Chat Input Controls Container */
#chat-input-controls {
    grid-area: chat-input-controls;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-end;
    gap: 20px;
    align-self: end;
    justify-self: stretch;
}
#input-methods-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    max-width: 550px;
}
#chat-controls-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
    flex-shrink: 0;
}
#chat-hints-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    min-height: 40px; /* Matches switch-to-voice button height (padding + font + border) */
}
/* Input Mode Styles */
.input-mode {
    display: none;
    width: 100%;
}
.input-mode.visible {
    display: flex;
}
#user-chat-input-container {
    position: relative;
    width: 100%;
    max-width: 100%; 
    background: rgba(30, 30, 30, 0.9);
    backdrop-filter: blur(5px);
    padding: 12px;
    box-sizing: border-box;
    z-index: 1002;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
}
.input-wrapper {
    display: flex;
    width: 100%;
}
#user-chat-input {
    flex-grow: 1;
    background-color: #111;
    border: 1px solid #444;
    color: #ffffff;
    font-size: 16px;
    padding: 12px 15px;
    border-radius: 8px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}
#user-chat-input:focus {
    border-color: #00AFFF;
    box-shadow: 0 0 0 3px rgba(0, 175, 255, 0.3);
}
#user-chat-input::placeholder {
    color: #888;
}
#user-chat-send-button {
    background: #0084ff;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0 25px;
    margin-left: 12px;
    cursor: pointer;
    font-weight: bold;
    font-size: 16px;
    transition: background-color 0.2s ease, transform 0.1s ease;
}
#user-chat-send-button:hover {
    background-color: #007ae6;
}
#user-chat-send-button:active {
    transform: scale(0.96);
}
#exit-chat-button {
    position: relative;
    z-index: 1003;
    background: #d9534f;
    color: white;
    border: none;
    border-radius: 8px;
    width: auto;
    height: auto;
    padding: 10px 20px;
    font-size: 16px;
    line-height: 1.2;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
#exit-chat-button.live-chat-visible {
    bottom: 420px; 
}
@media (max-width: 768px) {
    #user-chat-input-container {
        width: calc(100% - 90px);
        left: auto;
        right: 20px;
        transform: none;
    }
    #exit-chat-button.live-chat-visible {
        bottom: calc(50vh + 20px); 
    }
}
#exit-chat-button::before {
    content: ''; 
}
#exit-chat-button:hover {
    background: #c9302c;
    transform: scale(1.1);
}
.exit-text {
    display: block; 
    font-weight: bold;
}
/* Voice Input styles */
#voice-input-container {
    gap: 15px;
    color: #e0e5f0;
    justify-content: flex-start;
    align-items: center;
    background: rgba(30, 30, 30, 0.9);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    padding: 12px 20px;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
    max-width: 550px;
    box-sizing: border-box;
    width: 100%;
    cursor: pointer;
    transition: all 0.3s ease;
}
#voice-input-container.recording {
    border: 2px solid rgba(231, 76, 60, 0.8);
    box-shadow: 0 8px 25px rgba(231, 76, 60, 0.4), 0 0 20px rgba(231, 76, 60, 0.3);
    transform: scale(1.02);
}
#voice-input-container.recording .mic-button {
    background-color: #c0392b;
    border-color: #e74c3c;
    transform: scale(0.95);
}
#voice-input-container.recording .mic-button svg {
    fill: #ffffff;
}
#voice-input-container:hover:not(.recording) {
    background: rgba(40, 40, 40, 0.9);
    border-color: rgba(255,255,255,0.2);
    transform: translateY(-1px);
}
.mic-button {
    background-color: #2c3e50;
    border: 2px solid #34495e;
    border-radius: 50%;
    width: 64px;
    height: 64px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s, transform 0.1s;
}
.mic-button svg {
    width: 32px;
    height: 32px;
    fill: #ecf0f1;
    transition: fill 0.2s;
}
.mic-button:hover {
    background-color: #34495e;
}
.mic-button:active {
    background-color: #c0392b;
    border-color: #e74c3c;
    transform: scale(0.95);
}
.mic-button:active svg {
    fill: #ffffff;
}
.record-instruction {
    font-size: 16px;
    flex: 1;
}
.chat-hint {
    font-size: 14px;
    color: #95a5a6;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.chat-hint.visible {
    opacity: 1;
    pointer-events: auto;
}
.text-mode-hint {
    font-size: 14px;
    color: #95a5a6;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.text-mode-hint.visible {
    opacity: 1;
    pointer-events: auto;
}
.chat-hint kbd,
.text-mode-hint kbd {
    display: inline-block;
    padding: 3px 8px;
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
    color: #2c3e50;
    background: #ecf0f1;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    box-shadow: 0 2px 0 #bdc3c7;
    margin: 0 4px;
}
/* Switch to Voice Button */
.switch-mode-button {
    background: #28a745;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: none;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
    flex-shrink: 0;
}
.switch-mode-button.visible {
    display: flex;
}
.switch-mode-button:hover {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
}
.switch-mode-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(40, 167, 69, 0.3);
}
.switch-mode-button .button-icon {
    font-size: 16px;
}