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

body {
    background: #f0f2f5;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 20px;
}

.main-content {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.chat-container {
    flex: 1;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

@media (min-width: 768px) {
    .chat-container {
        flex-direction: row;
    }
}

.waifu-image-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

#waifu-image {
    width: 100%;
    max-width: 300px;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.2);
}

.chat-area {
    flex: 2;
    display: flex;
    flex-direction: column;
}

.conversation {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    height: 400px;
    background: #fafafa;
    margin-bottom: 10px;
}

.input-area {
    display: flex;
    gap: 10px;
}

#user-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
}

button {
    cursor: pointer;
    background: #8e44ad;
    color: white;
    border: none;
    border-radius: 20px;
    padding: 10px 20px;
    font-weight: bold;
    transition: background 0.3s;
}

button:hover {
    background: #6c3483;
}

.icon-button {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background: #8e44ad;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
}

.icon-button:hover {
    background: #6c3483;
}

.character-customization {
    flex: 1;
    min-width: 300px;
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

h3 {
    margin-bottom: 15px;
    color: #8e44ad;
}

.traits-input {
    margin-bottom: 15px;
}

#traits-description {
    width: 100%;
    height: 80px;
    padding: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    margin-bottom: 10px;
    resize: none;
}

.trait-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.trait-suggestion {
    padding: 8px 15px;
    background: #f0e6f6;
    border-radius: 15px;
    cursor: pointer;
    font-size: 14px;
}

.trait-suggestion:hover {
    background: #e5d5f0;
}

.save-character {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

#character-name {
    flex: 1;
    padding: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
}

.saved-characters {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.saved-character {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #f0e6f6;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.3s;
}

.saved-character:hover {
    background: #e5d5f0;
}

.saved-character-info {
    flex: 1;
}

.saved-character-name {
    font-weight: bold;
    margin-bottom: 5px;
}

.saved-character-traits {
    font-size: 12px;
    color: #666;
}

.delete-character {
    color: #e74c3c;
    cursor: pointer;
    padding: 5px;
}

.message {
    margin-bottom: 15px;
    padding: 10px;
    border-radius: 10px;
    max-width: 80%;
}

.user-message {
    background: #e5d5f0;
    align-self: flex-end;
    margin-left: auto;
}

.bot-message {
    background: #f0e6f6;
    align-self: flex-start;
}

/* Loader animation */
.loader {
    display: none;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

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

#send-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 80px;
}

#regenerate-image {
    width: auto;
    border-radius: 20px;
    margin-top: 10px;
}

.tts-toggle {
    margin-top: 10px;
    background-color: #8e44ad;
}

.tts-toggle.active {
    background-color: #27ae60;
}

.tts-toggle.disabled {
    background-color: #e74c3c;
}

.ai-mode {
    background-color: #8e44ad;
}

.fallback-mode {
    background-color: #e67e22;
}

#ai-toggle {
    width: auto;
    border-radius: 20px;
    margin-top: 10px;
    padding: 7px 15px;
    display: flex;
    align-items: center;
    gap: 5px;
}