* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --secondary-color: #ec4899;
    --accent-color: #fbbf24;
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --text-color: #1f2937;
    --card-bg: white;
    --shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Comic Sans MS', 'Arial Rounded MT Bold', 'Helvetica Rounded', Arial, sans-serif;
    background: var(--bg-gradient);
    color: var(--text-color);
    overflow: hidden;
    height: 100vh;
}

.screen {
    display: none;
    width: 100%;
    height: 100vh;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.screen.active {
    display: flex;
    opacity: 1;
}

/* Splash Screen */
#splash-screen {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

#splash-screen::before {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 1px, transparent 1px);
    background-size: 50px 50px;
    animation: moveBackground 20s linear infinite;
}

@keyframes moveBackground {
    0% { transform: translate(0, 0); }
    100% { transform: translate(50px, 50px); }
}

.logo-container {
    position: relative;
    z-index: 1;
    text-align: center;
}

.logo-text {
    font-size: 5rem;
    color: white;
    text-shadow: 
        0 0 20px rgba(255, 255, 255, 0.5),
        0 5px 15px rgba(0, 0, 0, 0.3);
    animation: float 3s ease-in-out infinite;
    font-weight: bold;
    letter-spacing: 3px;
}

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

.sparkles {
    font-size: 3rem;
    animation: sparkle 2s ease-in-out infinite;
    margin-top: 20px;
}

@keyframes sparkle {
    0%, 100% { 
        opacity: 0.5;
        transform: scale(1);
    }
    50% { 
        opacity: 1;
        transform: scale(1.2);
    }
}

.wakeword-indicator {
    position: absolute;
    bottom: 120px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    padding: 20px 40px;
    border-radius: 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 1;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    animation: fadeInUp 1s ease-out 0.5s both;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wakeword-indicator.listening {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    }
    50% {
        box-shadow: 0 8px 32px rgba(255, 255, 255, 0.4), 0 0 40px rgba(255, 255, 255, 0.3);
    }
}

.mic-icon {
    font-size: 3rem;
    animation: micBounce 2s ease-in-out infinite;
}

@keyframes micBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.wakeword-indicator.listening .mic-icon {
    animation: micPulse 1s ease-in-out infinite;
}

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

.wakeword-text {
    color: white;
    font-size: 1.3rem;
    font-weight: bold;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    margin: 0;
}

.waveform {
    display: flex;
    gap: 5px;
    align-items: center;
    height: 40px;
    opacity: 0;
    transition: opacity 0.3s;
}

.wakeword-indicator.listening .waveform {
    opacity: 1;
}

.wave-bar {
    width: 4px;
    background: white;
    border-radius: 2px;
    animation: waveAnimation 1s ease-in-out infinite;
}

.wave-bar:nth-child(1) { animation-delay: 0s; height: 10px; }
.wave-bar:nth-child(2) { animation-delay: 0.1s; height: 20px; }
.wave-bar:nth-child(3) { animation-delay: 0.2s; height: 30px; }
.wave-bar:nth-child(4) { animation-delay: 0.3s; height: 20px; }
.wave-bar:nth-child(5) { animation-delay: 0.4s; height: 10px; }

@keyframes waveAnimation {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(1.5); }
}

.tap-hint {
    position: absolute;
    bottom: 40px;
    color: white;
    font-size: 1.1rem;
    animation: pulse 2s ease-in-out infinite;
    z-index: 1;
    opacity: 0.7;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.9; }
}

/* Login Screen */
#login-screen {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0e7ff 100%);
    padding: 20px;
}

.login-container {
    background: var(--card-bg);
    border-radius: 30px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    max-width: 450px;
    width: 100%;
    animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.login-header p {
    font-size: 1.3rem;
    color: #6b7280;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-group label {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.label-icon {
    font-size: 1.5rem;
}

.form-group input {
    font-family: inherit;
    font-size: 1.2rem;
    padding: 15px 20px;
    border: 3px solid var(--primary-color);
    border-radius: 15px;
    background: #f9fafb;
    transition: all 0.3s ease;
    outline: none;
}

.form-group input:focus {
    border-color: var(--secondary-color);
    background: white;
    box-shadow: 0 0 0 4px rgba(236, 72, 153, 0.1);
    transform: translateY(-2px);
}

.form-group input::placeholder {
    color: #9ca3af;
}

.login-button {
    font-family: inherit;
    font-size: 1.4rem;
    font-weight: bold;
    padding: 18px 30px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.3);
}

.login-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}

.login-button:active {
    transform: translateY(-1px);
}

.button-icon {
    font-size: 1.6rem;
    transition: transform 0.3s ease;
}

.login-button:hover .button-icon {
    transform: translateX(5px);
}

.login-error {
    background: #fee2e2;
    color: #991b1b;
    padding: 15px;
    border-radius: 12px;
    text-align: center;
    font-size: 1.1rem;
    font-weight: bold;
    border: 2px solid #fca5a5;
    animation: shake 0.5s ease;
}

.login-error.hidden {
    display: none;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.login-hint {
    margin-top: 20px;
    text-align: center;
    font-size: 1rem;
    color: #6b7280;
    padding: 12px;
    background: #f3f4f6;
    border-radius: 10px;
    border: 2px dashed #d1d5db;
}

/* Main Screen */
#main-screen {
    flex-direction: column;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0e7ff 100%);
}

header {
    padding: 20px;
    background: var(--card-bg);
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

header h1 {
    font-size: 2rem;
    color: var(--primary-color);
    text-align: center;
    flex: 1;
}

.voice-btn {
    position: absolute;
    right: 20px;
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    background: var(--primary-color);
    font-size: 2rem;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: transform 0.2s, background 0.3s;
}

.voice-btn:hover {
    transform: scale(1.1);
}

.voice-btn:active {
    transform: scale(0.95);
}

.voice-btn.listening {
    background: var(--secondary-color);
    animation: voicePulse 1s ease-in-out infinite;
}

@keyframes voicePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(236, 72, 153, 0.7); }
    50% { box-shadow: 0 0 0 15px rgba(236, 72, 153, 0); }
}

main {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
}

.subjects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 20px;
    max-width: 900px;
    margin: 0 auto;
}

.subject-card {
    background: var(--card-bg);
    border: 4px solid var(--primary-color);
    border-radius: 20px;
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
    font-family: inherit;
}

.subject-card:hover {
    transform: translateY(-10px) scale(1.05);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
    border-color: var(--secondary-color);
}

.subject-card:active {
    transform: translateY(-5px) scale(1.02);
}

.subject-icon {
    font-size: 4rem;
    animation: bounce 2s ease-in-out infinite;
}

.subject-card:nth-child(1) { animation-delay: 0s; }
.subject-card:nth-child(2) { animation-delay: 0.1s; }
.subject-card:nth-child(3) { animation-delay: 0.2s; }
.subject-card:nth-child(4) { animation-delay: 0.3s; }
.subject-card:nth-child(5) { animation-delay: 0.4s; }
.subject-card:nth-child(6) { animation-delay: 0.5s; }
.subject-card:nth-child(7) { animation-delay: 0.6s; }
.subject-card:nth-child(8) { animation-delay: 0.7s; }

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

.subject-name {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--text-color);
}

.voice-status {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--secondary-color);
    color: white;
    padding: 15px 30px;
    border-radius: 50px;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow);
    transition: opacity 0.3s;
}

.voice-status.hidden {
    display: none;
}

.voice-status .pulse {
    width: 15px;
    height: 15px;
    background: white;
    border-radius: 50%;
    animation: pulseCircle 1s ease-in-out infinite;
}

@keyframes pulseCircle {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.5; }
}

/* Responsive Design */
@media (max-width: 768px) {
    .logo-text {
        font-size: 3.5rem;
    }
    
    .login-container {
        padding: 30px 25px;
    }
    
    .login-header h1 {
        font-size: 2rem;
    }
    
    .login-header p {
        font-size: 1.1rem;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .subjects-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .subject-card {
        padding: 20px 10px;
    }
    
    .subject-icon {
        font-size: 3rem;
    }
    
    .subject-name {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .logo-text {
        font-size: 2.5rem;
    }
    
    .login-container {
        padding: 25px 20px;
    }
    
    .login-header h1 {
        font-size: 1.8rem;
    }
    
    .form-group input {
        font-size: 1.1rem;
        padding: 12px 15px;
    }
    
    .login-button {
        font-size: 1.2rem;
        padding: 15px 25px;
    }
    
    main {
        padding: 15px;
    }
}

/* Chat Screen */
#chat-screen {
    flex-direction: column;
    background: #f3f4f6;
}

.chat-header {
    background: var(--card-bg);
    padding: 15px 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 15px;
    min-height: 70px;
}

.back-button {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary-color);
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 10px;
    transition: all 0.2s;
    font-family: inherit;
}

.back-button:hover {
    background: #f3f4f6;
    transform: translateX(-3px);
}

.chat-subject-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.chat-subject-icon {
    font-size: 2.5rem;
}

.chat-subject-info h1 {
    font-size: 1.8rem;
    color: var(--primary-color);
}

.spacer {
    width: 100px;
}

/* Chat Messages */
.chat-main {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    display: flex;
    gap: 10px;
    max-width: 80%;
    animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    font-size: 2.5rem;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message-content {
    background: white;
    padding: 12px 18px;
    border-radius: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
}

.user-message .message-content {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.message-content p {
    margin: 0;
    font-size: 1.1rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.message-time {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 5px;
    display: block;
}

.user-message .message-time {
    color: rgba(255, 255, 255, 0.8);
    text-align: right;
}

/* Message with media */
.message-media {
    margin-top: 8px;
    border-radius: 12px;
    overflow: hidden;
    max-width: 250px;
}

.message-media img {
    width: 100%;
    height: auto;
    display: block;
}

.message-media audio {
    width: 100%;
    max-width: 250px;
}

/* Chat Footer */
.chat-footer {
    background: var(--card-bg);
    padding: 15px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.media-preview {
    padding: 10px;
    margin-bottom: 10px;
    background: #f9fafb;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.media-preview.hidden {
    display: none;
}

.preview-content {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.preview-image {
    max-width: 200px;
    max-height: 200px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.preview-audio {
    width: 100%;
    max-width: 300px;
}

.preview-image.hidden,
.preview-audio.hidden {
    display: none;
}

.remove-media-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
    transition: transform 0.2s;
}

.remove-media-btn:hover {
    transform: scale(1.1);
}

.chat-input-container {
    display: flex;
    gap: 10px;
    align-items: center;
}

.media-button {
    background: #f3f4f6;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    width: 50px;
    height: 50px;
    font-size: 1.8rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-button:hover {
    background: #e5e7eb;
    transform: scale(1.05);
}

.media-button:active {
    transform: scale(0.95);
}

.media-button.recording {
    background: #fee2e2;
    border-color: #ef4444;
    animation: recordingPulse 1s ease-in-out infinite;
}

@keyframes recordingPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.chat-input {
    flex: 1;
    font-family: inherit;
    font-size: 1.1rem;
    padding: 12px 18px;
    border: 2px solid #e5e7eb;
    border-radius: 25px;
    background: #f9fafb;
    outline: none;
    transition: all 0.2s;
}

.chat-input:focus {
    border-color: var(--primary-color);
    background: white;
}

.send-button {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.send-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.send-button:active {
    transform: scale(0.95);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: scale(1);
}

/* Recording Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal.hidden {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 25px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-content h2 {
    color: var(--primary-color);
    font-size: 2rem;
    margin-bottom: 30px;
}

.recording-visualizer {
    width: 150px;
    height: 150px;
    margin: 0 auto 20px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.recording-pulse {
    width: 80px;
    height: 80px;
    background: var(--secondary-color);
    border-radius: 50%;
    animation: recordingPulseAnimation 1.5s ease-in-out infinite;
}

@keyframes recordingPulseAnimation {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.7;
    }
}

.recording-timer {
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-color);
    margin-bottom: 25px;
    font-family: 'Courier New', monospace;
}

.stop-recording-btn {
    font-family: inherit;
    font-size: 1.3rem;
    font-weight: bold;
    padding: 15px 40px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.stop-recording-btn:hover {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4);
}

.stop-recording-btn:active {
    transform: translateY(0);
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 15px 20px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typingAnimation 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingAnimation {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Responsive for wake word */
@media (max-width: 768px) {
    .wakeword-indicator {
        bottom: 100px;
        padding: 15px 30px;
    }
    
    .mic-icon {
        font-size: 2.5rem;
    }
    
    .wakeword-text {
        font-size: 1.1rem;
    }
    
    .tap-hint {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .wakeword-indicator {
        bottom: 80px;
        padding: 12px 25px;
    }
    
    .mic-icon {
        font-size: 2rem;
    }
    
    .wakeword-text {
        font-size: 1rem;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .chat-subject-info h1 {
        font-size: 1.4rem;
    }
    
    .chat-subject-icon {
        font-size: 2rem;
    }
    
    .message {
        max-width: 85%;
    }
    
    .message-avatar {
        font-size: 2rem;
        width: 40px;
        height: 40px;
    }
    
    .back-button {
        font-size: 1rem;
    }
    
    .spacer {
        width: 50px;
    }
}

@media (max-width: 480px) {
    .chat-header {
        padding: 12px 15px;
    }
    
    .chat-subject-info h1 {
        font-size: 1.2rem;
    }
    
    .message {
        max-width: 90%;
    }
    
    .message-content p {
        font-size: 1rem;
    }
    
    .chat-input {
        font-size: 1rem;
        padding: 10px 15px;
    }
    
    .media-button,
    .send-button {
        width: 45px;
        height: 45px;
        font-size: 1.5rem;
    }
    
    .spacer {
        display: none;
    }
}
