* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Arial', sans-serif;
}

body {
    background-color: #f8f0ff;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    padding-bottom: 80px;
}

.chat-container {
    display: flex;
    width: 100%;
    max-width: 1200px;
    background-color: white;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    position: relative;
    z-index: 10;
}

.waifu-section {
    flex: 1;
    padding: 20px;
    background-color: #ffe6f2;
    display: flex;
    flex-direction: column;
    min-width: 300px;
}

.waifu-image-container {
    position: relative;
    aspect-ratio: 1 / 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    border-radius: 10px;
    background-color: #fff;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 15px;
}

#waifu-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-controls {
    display: flex;
    gap: 10px;
}

#image-prompt {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid #ffb6c1;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
}

#update-image {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #ff8fa3;
    border: none;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
}

#update-image:hover {
    background-color: #ff6b84;
}

.chat-section {
    flex: 1.5;
    display: flex;
    flex-direction: column;
    border-left: 1px solid #f0f0f0;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: #ff8fa3;
    color: white;
}

.header-controls {
    display: flex;
    gap: 15px;
}

.chat-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

#copy-chat, #tts-toggle {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.1rem;
    transition: opacity 0.3s;
}

#copy-chat:hover, #tts-toggle:hover {
    opacity: 0.8;
}

#tts-toggle .fa-volume-up {
    color: #aaffaa;
}

#tts-toggle.loading {
    opacity: 0.7;
    cursor: wait;
}

#tts-toggle:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    max-height: 500px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    display: flex;
    margin-bottom: 10px;
}

.message.user {
    justify-content: flex-end;
}

.message-content {
    max-width: 80%;
    padding: 12px 15px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.4;
}

.message.waifu .message-content {
    background-color: #fff0f5;
    border-bottom-left-radius: 5px;
    color: #333;
}

.message.user .message-content {
    background-color: #ff8fa3;
    border-bottom-right-radius: 5px;
    color: white;
}

.chat-input {
    display: flex;
    padding: 15px;
    border-top: 1px solid #f0f0f0;
    background-color: white;
}

#user-input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #ffb6c1;
    border-radius: 20px;
    font-size: 0.95rem;
    outline: none;
    margin-right: 10px;
}

#send-message {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: none;
    background-color: #ff8fa3;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

#send-message:hover {
    background-color: #ff6b84;
}

#send-message:disabled {
    background-color: #fcc2d0;
    cursor: not-allowed;
}

#send-message:disabled:hover {
    background-color: #fcc2d0;
}

#send-message i {
    display: block;
}

.sending-spinner {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
}

.image-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 139, 163, 0.3);
    border-radius: 50%;
    border-top-color: #ff8fa3;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

#tts-audio {
    display: none;
    width: 0;
    height: 0;
}

#tts-error {
    color: #d9534f;
    padding: 5px 20px 10px;
    font-size: 0.85em;
    text-align: center;
    display: none;
}

.radio-player {
    position: fixed;
    bottom: 15px;
    left: 15px;
    background-color: #ffccd5;
    border: 1px solid #ffb3c1;
    border-radius: 25px;
    padding: 8px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 100;
}

.radio-icon {
    font-size: 1.2rem;
    color: #e6739f;
    user-select: none;
}

#radio-play-pause {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0 5px;
    color: #e6739f;
    line-height: 1;
}

#radio-play-pause:hover {
    opacity: 0.8;
}

#radio-volume {
    cursor: pointer;
    width: 80px;
    height: 8px;
    appearance: none;
    background: #ffe6f2;
    border-radius: 5px;
    outline: none;
}

#radio-volume::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: #ff8fa3;
    border-radius: 50%;
    cursor: pointer;
}

#radio-volume::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #ff8fa3;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

#radio-error {
    color: #d9534f;
    font-size: 0.8em;
    margin-left: 5px;
    display: none;
}

@media (max-width: 768px) {
    body {
        padding-bottom: 100px;
    }
    .chat-container {
        flex-direction: column;
        height: calc(100vh - 40px);
        width: 100%;
        max-width: none;
        margin: 0;
        border-radius: 0;
    }

    .waifu-section {
        height: auto;
        padding: 15px;
    }

    .waifu-image-container {
        max-width: 200px;
        margin: 0 auto 15px auto;
    }

    .chat-section {
        flex: 1;
        min-height: 0;
    }

    .chat-messages {
        flex-grow: 1;
        max-height: none;
    }

    .radio-player {
        bottom: 10px;
        left: 10px;
        right: 10px;
        width: auto;
        justify-content: center;
        padding: 8px 10px;
    }

    #radio-volume {
        width: 60px;
    }
}