:root {
    --primary: #FFB7B2; /* Pastel Pink */
    --secondary: #B2E2F2; /* Pastel Blue */
    --accent: #FFFFB2; /* Pastel Yellow */
    --bg-main: #f9f9fb;
    --text-primary: #4A4A4A;
    --white: #ffffff;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --glass: rgba(255, 255, 255, 0.45);
    --glass-border: rgba(255, 255, 255, 0.6);
    --bubble-bot: #F0F4F8;
    --bubble-user: linear-gradient(135deg, #FF99AC 0%, #FFB7B2 100%);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Outfit', sans-serif;
    background: linear-gradient(135deg, #FFDEE9 0%, #B5FFFC 100%);
    color: var(--text-primary);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-container {
    width: 100%;
    max-width: 480px;
    height: 90vh;
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 40px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    margin: 20px;
    z-index: 10;
}

.background-decorations {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}

.deco-star {
    position: absolute;
    background: white;
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    opacity: 0.4;
    animation: twinklestar 5s infinite ease-in-out;
}

@keyframes twinklestar {
    0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.3; }
    50% { transform: scale(1.5) rotate(180deg); opacity: 0.6; }
}

header {
    padding: 24px;
    text-align: center;
    border-bottom: 1px solid var(--glass-border);
}

.logo {
    font-family: 'Fredoka', cursive;
    font-size: 28px;
    font-weight: 700;
    color: #FF85A1;
    text-shadow: 0 2px 4px rgba(255, 133, 161, 0.2);
}

/* Config Button & Modal */
button#config-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: none;
    color: #FF85A1;
    cursor: pointer;
    z-index: 100;
    opacity: 0.6;
    transition: all 0.3s;
}

button#config-btn:hover {
    opacity: 1;
    transform: rotate(90deg);
}

button#config-btn svg {
    width: 24px;
    height: 24px;
}

.modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 30px;
    width: 85%;
    max-width: 350px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.modal-content h3 {
    margin-bottom: 15px;
    color: #FF85A1;
    font-family: 'Fredoka', cursive;
}

.modal-content p {
    font-size: 14px;
    margin-bottom: 20px;
    color: #666;
}

.modal-content input {
    width: 100%;
    padding: 12px;
    border: 2px solid #FFDEE9;
    border-radius: 15px;
    margin-bottom: 20px;
    font-size: 14px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 15px;
}

.modal-buttons button {
    padding: 10px 20px;
    border-radius: 20px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

#save-key-btn {
    background: #FF85A1;
    color: white;
}

#close-modal-btn {
    background: #f0f0f0;
    color: #666;
}

.modal-content small a {
    color: #FF85A1;
    text-decoration: none;
    font-size: 12px;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 20px;
}

.character-section {
    flex: 0 0 180px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.character-wrapper {
    position: relative;
    width: 140px;
    height: 140px;
}

.character-wrapper img {
    width: 100%;
    height: auto;
    z-index: 2;
    position: relative;
}

.glow-effect {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120%;
    height: 120%;
    background: radial-gradient(circle, rgba(255, 222, 233, 0.8) 0%, rgba(181, 255, 252, 0) 70%);
    z-index: 1;
    filter: blur(10px);
    animation: glow-pulse 3s infinite ease-in-out;
}

.chat-section {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    scrollbar-width: thin;
    scrollbar-color: #FFB7B2 transparent;
}

.chat-section::-webkit-scrollbar {
    width: 6px;
}

.chat-section::-webkit-scrollbar-track {
    background: transparent;
}

.chat-section::-webkit-scrollbar-thumb {
    background-color: #FFB7B2;
    border-radius: 10px;
}

/* Animations */
@keyframes glow-pulse {
    0%, 100% { opacity: 0.5; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
}

.floating {
    animation: floating 4s ease-in-out infinite;
}

@keyframes floating {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.speaking {
    animation: speaking 0.2s infinite ease-in-out;
}

@keyframes speaking {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02) translateY(-2px); }
}

.magic-glow {
    animation: magic-glow 2s infinite alternate ease-in-out;
}

@keyframes magic-glow {
    0% { filter: drop-shadow(0 0 5px rgba(255, 222, 178, 0.5)); }
    100% { filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.8)); }
}

.chat-history {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    max-width: 80%;
    padding: 12px 18px;
    border-radius: 20px;
    font-size: 15px;
    animation: message-in 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes message-in {
    from { opacity: 0; transform: translateY(10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.message.bot {
    align-self: flex-start;
    background: var(--bubble-bot);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.message.user {
    align-self: flex-end;
    background: var(--bubble-user);
    color: var(--white);
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(255, 133, 161, 0.2);
}

.message.system {
    align-self: center;
    background: transparent;
    font-size: 13px;
    color: #888;
    text-align: center;
}

.typing-indicator {
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 20px;
    width: fit-content;
    display: flex;
    gap: 4px;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: #FF85A1;
    border-radius: 50%;
    animation: typing 1s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 100% { transform: translateY(0); opacity: 0.4; }
    50% { transform: translateY(-4px); opacity: 1; }
}

.hidden { display: none; }

footer {
    padding: 20px;
    background: rgba(255, 255, 255, 0.4);
    border-top: 1px solid var(--glass-border);
}

.input-wrapper {
    display: flex;
    align-items: center;
    background: var(--white);
    border-radius: 30px;
    padding: 6px;
    box-shadow: var(--shadow);
    margin-bottom: 15px;
    gap: 8px;
}

button#mic-btn {
    width: 44px;
    height: 44px;
    background: #FF85A1;
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

button#mic-btn.active {
    background: #FF2E63;
    animation: mic-pulse 1.5s infinite ease-in-out;
}

@keyframes mic-pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 46, 99, 0.7); }
    70% { box-shadow: 0 0 0 12px rgba(255, 46, 99, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 46, 99, 0); }
}

button#mic-btn svg {
    width: 20px;
    height: 20px;
}

#ai-status {
    font-size: 18px;
    margin: 0 5px 0 10px;
    transition: all 0.3s;
    filter: grayscale(1);
    opacity: 0.5;
    cursor: help;
}

#ai-status.connected {
    filter: grayscale(0);
    opacity: 1;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
    animation: status-pulse 3s infinite;
}

@keyframes status-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

input {
    flex: 1;
    border: none;
    outline: none;
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    color: var(--text-primary);
    padding: 10px 5px;
}

button#send-btn {
    width: 44px;
    height: 44px;
    background: #FF85A1;
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s, background 0.2s;
}

button#send-btn:hover {
    transform: scale(1.05);
    background: #FF668B;
}

button#send-btn svg {
    width: 20px;
    height: 20px;
}

.quick-questions {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 5px;
    scrollbar-width: none;
}

.quick-questions::-webkit-scrollbar { display: none; }

.quick-btn {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 15px;
    font-size: 13px;
    color: #FF85A1;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.quick-btn:hover {
    background: #FF85A1;
    color: white;
}

/* Mobile responsive fixes */
@media (max-width: 480px) {
    body {
        padding: 0;
    }
    .app-container {
        height: 100vh;
        height: 100dvh;
        margin: 0;
        border-radius: 0;
    }
    .character-section {
        flex: 0 0 160px;
    }
    .character-wrapper {
        width: 120px;
        height: 120px;
    }
    .logo {
        font-size: 24px;
    }
}

/* Landscape/Short screens */
@media (max-height: 600px) {
    .character-section {
        display: none;
    }
}
