@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Space+Mono:wght@400;700&display=swap');

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

:root {
    --dark-primary: #0a0a0a; /* Ultra dark onyx */
    --dark-secondary: #121212; /* Deep onyx */
    --dark-accent: #1a1a1a; /* Onyx accent */
    --glass-background: rgba(8, 8, 8, 0.85); /* Ultra dark onyx glass */
    --glass-border: rgba(30, 30, 30, 0.15); /* Subtle onyx border */
    --text-primary: #f5f5f5; /* Bright white text */
    --text-secondary: #b8b8b8; /* Medium grey for secondary text */
    --button-background: rgba(15, 15, 15, 0.7); /* Flat dark buttons */
    --button-hover: rgba(25, 25, 25, 0.8); /* Slightly lighter on hover */
    --arrow-color: #ffffff; /* White for the arrow */
}

body {
    font-family: 'Space Mono', monospace;
    background: #000; /* Pure black background */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-primary);
    padding: 0; /* Removed padding to allow content to go all the way up */
    position: relative;
    overflow-x: hidden;
    margin: 0; /* Ensure no default body margin */
    overflow: hidden; /* Prevent scrollbars */
}

/* Animated background - adjusted for dark theme, removed color gradients */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    opacity: 0.3;
    z-index: -2;
}


/* Noise texture overlay - adjusted for dark theme */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 2px,
            rgba(255, 255, 255, 0.01) 2px,
            rgba(255, 255, 255, 0.01) 4px
        );
    pointer-events: none;
    z-index: -1;
    mix-blend-mode: overlay;
}

/* Floating particles */
.particle {
    position: fixed;
    pointer-events: none;
    opacity: 0.4;
    z-index: 50;
}

/* Setup modal styles */
.setup-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 10px;
    z-index: 1000;
}

/* Removed colored border gradient for setup-content::before */
.setup-content::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, var(--dark-primary), var(--dark-secondary), var(--dark-accent), var(--dark-primary));
    border-radius: 24px;
    opacity: 0.7;
    z-index: -1;
    animation: borderGradient 4s linear infinite;
}

.setup-content h2 {
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    font-size: 2em;
    margin-bottom: 10px;
    background: linear-gradient(135deg, var(--text-primary), var(--text-secondary)); /* Grey gradient for text */
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-transform: uppercase;
    letter-spacing: 3px;
}

.setup-content p {
    color: var(--text-secondary);
    margin-bottom: 30px;
    font-size: 0.9em;
}

.setup-content label {
    display: block;
    margin-bottom: 8px;
    text-align: left;
    font-size: 0.8em;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.setup-content input {
    width: 100%;
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05); /* Subtle input background */
    color: var(--text-primary);
    font-family: 'Space Mono', monospace;
    transition: all 0.3s ease;
}

.setup-content input:focus {
    outline: none;
    border-color: var(--dark-accent); /* Dark accent on focus */
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5); /* Darker shadow on focus */
    transform: translateY(-2px);
}

.setup-content button {
    width: 100%;
    background: var(--button-background); /* Solid dark button */
    color: var(--text-primary);
    padding: 15px 30px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 1em;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.setup-content button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.1); /* Subtle white ripple */
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.setup-content button:hover::before {
    width: 300px;
    height: 300px;
}

.setup-content button:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); /* Darker hover shadow */
    background: var(--button-hover);
}

/* Main container */
.main-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: block;
    flex-direction: column;
    max-width: 800px;
    background: var(--glass-background);
    backdrop-filter: blur(30px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.7),
        inset 0 0 30px rgba(255, 255, 255, 0.03);
    overflow: hidden;
    flex-grow: 1;
    z-index: 10;
}

.header-bar {
    padding: 18px;
    background: rgba(8, 8, 8, 0.5);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
}

.header-title {
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    font-size: 1.2em;
    background: linear-gradient(135deg, var(--text-primary), var(--text-secondary)); /* Grey gradient for text */
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-transform: uppercase;
    letter-spacing: 3px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8em;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary); /* Grey dot */
    animation: pulse 2s ease-in-out infinite;
}

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

/* Live2D canvas container */
#live2d-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    overflow: hidden;
    /* Hardware acceleration for better performance */
    transform: translateZ(0);
    will-change: transform;
    -webkit-transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;

    background-image: url('background2.jpg');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: scroll; /* Changed from fixed for better mobile performance */
}

#live2d-container::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100px;
    background: linear-gradient(to top, var(--glass-background), transparent); /* Darker gradient */
    pointer-events: none;
}

#live2d-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Hardware acceleration for canvas */
    transform: translateZ(0);
    will-change: transform;
    -webkit-transform: translateZ(0);
    image-rendering: optimizeSpeed;
    image-rendering: -webkit-optimize-contrast;
}

/* Chat window overlay */
#chat-window {
    position: absolute;
    bottom: 95px; /* Moved up to create space above input */
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 800px;
    max-height: 40%; /* Max height for scrollable chat */
    display: flex;
    flex-direction: column-reverse; /* New messages appear at bottom */
    overflow-y: auto; /* Enable scrolling */
    z-index: 10;
    pointer-events: none; /* Allow clicks to pass through by default */
    background: none;
    border: none;
    padding: 0; /* No padding on container itself */
    gap: 15px; /* Spacing between messages */
}

/* Custom scrollbar */
#chat-window::-webkit-scrollbar {
    width: 6px;
}

#chat-window::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

#chat-window::-webkit-scrollbar-thumb {
    background: var(--dark-accent); /* Dark grey scrollbar thumb */
    border-radius: 3px;
}

/* Individual message styling */
.message {
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(0.5px);
    -webkit-backdrop-filter: blur(0.5px);
    color: var(--text-primary);
    padding: 14px 18px;
    border-radius: 16px;
    margin-bottom: 8px;
    max-width: 75%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.03);
    opacity: 1;
    transition: opacity 0.5s ease;
    pointer-events: all;
    transform: translateZ(0);
    word-wrap: break-word;
    line-height: 1.6;
    animation: messageSlide 0.3s ease-out;
    will-change: opacity;
}

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

.message.fading-out {
    opacity: 0;
}

.message.ai {
    align-self: flex-start;
    background: var(--glass-background); /* Dark glass background */
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    box-shadow:
        0 5px 15px rgba(0, 0, 0, 0.3), /* Darker shadow */
        inset 0 0 20px rgba(255, 255, 255, 0.02); /* Subtle inner glow */
}

/* Removed colored shimmer for ai message */
.message.ai::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    background: linear-gradient(45deg, rgba(50,50,50,0.5), transparent, rgba(70,70,70,0.5)); /* Dark grey gradient */
    border-radius: 20px;
    opacity: 0.5;
    z-index: -1;
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.8; }
}

.message.user {
    align-self: flex-end;
    background: rgba(0, 0, 0, 0.30);
    border: 1px solid rgba(255, 255, 255, 0.04);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

/* =================================================================== */
/* DEPRECATED - REMOVED DUPLICATE CHAT INPUT STYLES */
/* =================================================================== */

/* ===============================================================
   PRODUCTION-QUALITY INPUT SYSTEM - MODERN AI CHATBOX DESIGN
   =============================================================== */

.input-area {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 800px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: transparent !important;
}

div[class*="input-wrapper"],
*[class*="input-wrapper"],
.input-wrapper,
div.input-wrapper {
    position: relative !important;
    background: rgba(0, 0, 0, 0.25) !important;
    backdrop-filter: blur(0.5px) !important;
    -webkit-backdrop-filter: blur(0.5px) !important;
    border: 1px solid rgba(255, 255, 255, 0.03) !important;
    border-radius: 16px;
    padding: 10px;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.02) !important;
    will-change: background-color, border-color;
}

.input-wrapper:focus-within {
    border-color: rgba(255, 255, 255, 0.06) !important;
    background: rgba(0, 0, 0, 0.35) !important;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.03) !important;
}

/* ATTACHMENT BUTTON - LEFT SIDE */
.attach-btn {
    flex-shrink: 0;
    background: rgba(15, 15, 15, 0.6);
    border: 1px solid rgba(30, 30, 30, 0.4);
    color: var(--text-primary);
    border-radius: 10px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.attach-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.3s ease;
}

.attach-btn:hover::before {
    width: 60px;
    height: 60px;
}

.attach-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.5;
    position: relative;
    z-index: 1;
}

.attach-btn:hover {
    background: transparent;
    border-color: #ff6600;
    transform: translateY(-1px);
}

.attach-btn:active {
    transform: translateY(0);
    background: rgba(255, 255, 255, 0.15);
}

/* TEXTAREA - BEAUTIFUL GLASS EFFECT */
.input-area .input-wrapper textarea,
.input-area #user-input,
.input-area textarea#user-input,
div.input-area div.input-wrapper textarea#user-input {
    flex: 1 !important;
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 10px !important;
    color: rgba(255, 255, 255, 0.95) !important;
    font-family: inherit !important;
    font-size: 16px !important;
    resize: none !important;
    outline: none !important;
    min-height: 20px !important;
    max-height: 120px !important;
    line-height: 1.5 !important;
    padding: 10px 14px !important;
    overflow-y: hidden !important;
    vertical-align: top !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
    transition: none !important;
    position: relative !important;
    box-shadow: none !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5) !important;
    will-change: auto !important;
}

.input-wrapper textarea::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), transparent, rgba(255, 255, 255, 0.02));
    border-radius: 12px;
    pointer-events: none;
    z-index: -1;
}

.input-wrapper textarea:focus,
#user-input:focus,
textarea#user-input:focus {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    transform: none !important;
}

.input-wrapper textarea::placeholder,
#user-input::placeholder,
textarea#user-input::placeholder {
    color: rgba(255, 255, 255, 0.4) !important;
    font-style: normal !important;
    font-weight: 300 !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8) !important;
}

.input-wrapper textarea::-webkit-scrollbar {
    display: none;
    width: 0;
}

.input-wrapper textarea::-webkit-scrollbar-thumb {
    display: none;
}

.input-wrapper textarea::-webkit-scrollbar-thumb:hover {
    display: none;
}

.input-wrapper textarea::-webkit-scrollbar-track {
    display: none;
}

/* RIGHT SIDE BUTTONS - MIC & SEND/STOP */
.input-buttons {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    align-items: center;
}

.mic-btn,
.send-btn {
    background: rgba(15, 15, 15, 0.6);
    border: 1px solid rgba(30, 30, 30, 0.4);
    color: var(--text-primary);
    border-radius: 10px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.mic-btn::before,
.send-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.3s ease;
}

.mic-btn:hover::before {
    width: 60px;
    height: 60px;
}

.send-btn:hover::before {
    display: none;
}

.mic-btn svg,
.send-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.5;
    position: relative;
    z-index: 1;
    transition: transform 0.2s ease;
}

.mic-btn:hover {
    background: rgba(25, 25, 25, 0.8);
    border-color: rgba(40, 40, 40, 0.6);
    transform: translateY(-1px);
}

.send-btn:hover {
    background: transparent;
    border-color: #6e66ff;
    transform: translateY(-1px);
}

.mic-btn:hover svg,
.send-btn:hover svg {
    transform: scale(1.05);
}

.mic-btn:active,
.send-btn:active {
    transform: translateY(0);
    background: rgba(255, 255, 255, 0.15);
}

/* SEND/STOP BUTTON STATES */
.send-btn.is-speaking {
    background: rgba(255, 100, 100, 0.15);
    border-color: rgba(255, 100, 100, 0.3);
    color: #ff6464;
}

.send-btn.is-speaking::before {
    background: rgba(255, 100, 100, 0.2);
}

.send-btn.is-speaking:hover {
    background: rgba(255, 100, 100, 0.25);
    border-color: rgba(255, 100, 100, 0.4);
    box-shadow: 0 0 20px rgba(255, 100, 100, 0.2);
}

/* MIC BUTTON STATES - ENHANCED */
.mic-btn.listening {
    background: rgba(255, 68, 68, 0.2);
    border-color: rgba(255, 68, 68, 0.4);
    color: #ff4444;
    animation: pulse-red 1.5s ease-in-out infinite;
}

.mic-btn.wake-word-detected {
    background: rgba(68, 255, 68, 0.2);
    border-color: rgba(68, 255, 68, 0.4);
    color: #44ff44;
    animation: pulse-green 0.5s ease-in-out 2;
}

.mic-btn.disabled {
    background: rgba(102, 102, 102, 0.2);
    border-color: rgba(102, 102, 102, 0.3);
    color: #666;
    cursor: not-allowed;
    opacity: 0.5;
}

.mic-btn.disabled:hover {
    transform: none;
    background: rgba(102, 102, 102, 0.2);
}

@keyframes pulse-red {
    0%, 100% { 
        box-shadow: 0 0 20px rgba(255, 68, 68, 0.4);
        transform: translate3d(0, 0, 0);
    }
    50% { 
        box-shadow: 0 0 40px rgba(255, 68, 68, 0.7);
        transform: translate3d(0, -1px, 0);
    }
}

@keyframes pulse-green {
    0%, 100% { 
        box-shadow: 0 0 20px rgba(68, 255, 68, 0.4);
        transform: translateY(0);
    }
    50% { 
        box-shadow: 0 0 40px rgba(68, 255, 68, 0.7);
        transform: translateY(-1px);
    }
}

/* STT STATUS - IMPROVED */
.stt-status {
    position: absolute;
    bottom: 110px;
    left: 20px;
    transform: none;
    font-size: 0.75em;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.stt-status.visible {
    opacity: 1;
    transform: translateY(-5px);
}

/* Rotating circle animation for processing state */
.processing-circle {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(159, 239, 0, 0.3);
    border-top: 2px solid rgba(159, 239, 0, 1);
    border-radius: 50%;
    animation: spin-processing 1s linear infinite;
    margin-right: 6px;
    vertical-align: middle;
}

@keyframes spin-processing {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===============================================================
   ACCESSIBILITY & INTERACTION ENHANCEMENTS
   =============================================================== */

/* Focus states for accessibility */
.attach-btn:focus,
.mic-btn:focus,
.send-btn:focus {
    outline: 2px solid rgba(255, 255, 255, 0.4);
    outline-offset: 2px;
}

/* Improved disabled state */
.input-wrapper textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.attach-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.send-btn:disabled {
    /* Allow send button to be clicked even when "disabled" - it serves as STOP button */
    opacity: 1 !important;
    cursor: pointer !important;
    pointer-events: auto !important;
    background: rgba(255, 255, 255, 0.08) !important;
}

/* Force send button to always be clickable */
.send-btn {
    pointer-events: auto !important;
    cursor: pointer !important;
    opacity: 1 !important;
}

/* Enhanced button feedback */
.attach-btn:not(:disabled):hover {
    box-shadow: 0 0 15px rgba(255, 102, 0, 0.3);
}

.mic-btn:not(:disabled):hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.send-btn:not(:disabled):hover {
    box-shadow: 0 0 15px rgba(110, 102, 255, 0.3);
}

/* Optimized state transitions - reduced scope */
.attach-btn, .mic-btn, .send-btn, .input-wrapper, .input-wrapper textarea {
    transition-property: background-color, border-color, opacity, transform;
    transition-duration: 0.15s;
    transition-timing-function: ease-out;
    will-change: background-color, border-color, transform;
}

/* High-contrast mode support */
@media (prefers-contrast: high) {
    .input-wrapper {
        border-color: rgba(255, 255, 255, 0.8) !important;
    }
    
    .attach-btn,
    .mic-btn,
    .send-btn {
        border-color: rgba(255, 255, 255, 0.6) !important;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .mic-btn.listening,
    .mic-btn.wake-word-detected {
        animation: none !important;
    }
}

/* Attachment preview - completely remove from document flow */
#attachment-preview {
    position: fixed !important;
    top: auto !important;
    bottom: 90px !important;
    left: 50% !important;
    transform: translateX(-50%) translateX(-30%) !important;
    right: auto !important;
    width: auto !important;
    height: auto !important;
    max-width: 280px !important;
    z-index: 10000 !important;
    display: none !important;
    flex-direction: column !important;
    gap: 6px !important;
    padding: 12px !important;
    margin: 0 !important;
    background: rgba(0, 0, 0, 0.05) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    border: none !important;
    border-radius: 12px !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15) !important;
    visibility: visible !important;
    pointer-events: auto !important;
    float: none !important;
    clear: none !important;
    animation: slideInFromLeft 0.3s ease-out !important;
}

@keyframes slideInFromLeft {
    from {
        opacity: 0;
        transform: translateX(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

#attachment-preview.visible {
    display: flex !important;
    flex-direction: column !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: none;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.9);
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.attachment-item::before {
    display: none;
}

.attachment-item:hover {
    background: rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
}

.attachment-thumb {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    object-fit: cover;
    border: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.attachment-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.15);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.7);
}

.attachment-icon svg {
    width: 14px;
    height: 14px;
}

.attachment-name {
    flex: 1;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-remove {
    background: rgba(255, 100, 100, 0.15);
    border: 1px solid rgba(255, 100, 100, 0.3);
    color: rgba(255, 100, 100, 0.9);
    cursor: pointer;
    padding: 2px;
    font-size: 12px;
    line-height: 1;
    border-radius: 4px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.attachment-remove:hover {
    background: rgba(255, 100, 100, 0.2);
    border-color: rgba(255, 100, 100, 0.4);
    color: rgba(255, 100, 100, 1);
    transform: scale(1.1);
}

/* Status message */
#status-message {
    position: absolute;
    bottom: 150px;
    right: 20px;
    font-size: 0.75em;
    color: var(--text-secondary);
    background: rgba(8, 8, 8, 0.85);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    padding: 6px 14px;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 100;
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.5s ease-in-out, transform 0.5s ease-in-out;
}

#status-message.fade-out {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
    transition-delay: 2.5s; /* Wait 2.5s before fading */
}

/* ===============================================================
   MOBILE & RESPONSIVE ENHANCEMENTS - PRODUCTION GRADE
   =============================================================== */

/* Enhanced viewport fixes for Safari vertical issue */
html {
    height: 100%;
    height: -webkit-fill-available;
    overflow: hidden;
}

body {
    min-height: 100vh;
    min-height: -webkit-fill-available;
    height: 100%;
    position: fixed;
    width: 100%;
    top: 0;
    left: 0;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
}

/* iOS Safari specific viewport fixes */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari detection and fixes */
    .main-container {
        height: 100vh;
        height: -webkit-fill-available;
        max-height: -webkit-fill-available;
        min-height: 100vh;
        min-height: -webkit-fill-available;
        position: relative;
        overflow: hidden;
    }
    
    #live2d-container {
        height: 100vh;
        height: -webkit-fill-available;
        max-height: -webkit-fill-available;
        min-height: 100vh;
        min-height: -webkit-fill-available;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        overflow: hidden;
    }
    
    /* Fix for iOS showing only half screen - force full height */
    body {
        height: 100vh;
        height: -webkit-fill-available;
        min-height: 100vh;
        min-height: -webkit-fill-available;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        overflow: hidden;
    }
    
    html {
        height: 100vh;
        height: -webkit-fill-available;
        min-height: 100vh;
        min-height: -webkit-fill-available;
        overflow: hidden;
    }
}

/* iOS 15+ specific fixes for viewport issues */
@supports (-webkit-touch-callout: none) and (height: 100dvh) {
    html, body {
        height: 100dvh !important;
        min-height: 100dvh !important;
    }
    
    .main-container {
        height: 100dvh !important;
        min-height: 100dvh !important;
        max-height: 100dvh !important;
    }
    
    #live2d-container {
        height: 100dvh !important;
        min-height: 100dvh !important;
        max-height: 100dvh !important;
    }
}

/* iOS device specific fixes using custom viewport height */
.ios-device,
body[data-platform="ios"] {
    height: calc(var(--real-vh, 1vh) * 100) !important;
    min-height: calc(var(--real-vh, 1vh) * 100) !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    overflow: hidden !important;
    -webkit-overflow-scrolling: touch !important;
}

.ios-device .main-container,
body[data-platform="ios"] .main-container {
    height: calc(var(--real-vh, 1vh) * 100) !important;
    min-height: calc(var(--real-vh, 1vh) * 100) !important;
    max-height: calc(var(--real-vh, 1vh) * 100) !important;
    width: 100vw !important;
    position: relative !important;
    overflow: hidden !important;
}

.ios-device #live2d-container,
body[data-platform="ios"] #live2d-container {
    height: calc(var(--real-vh, 1vh) * 100) !important;
    min-height: calc(var(--real-vh, 1vh) * 100) !important;
    max-height: calc(var(--real-vh, 1vh) * 100) !important;
    width: 100vw !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    overflow: hidden !important;
}

/* iOS input area specific positioning */
.ios-device .input-area,
body[data-platform="ios"] .input-area {
    position: fixed !important;
    bottom: env(safe-area-inset-bottom, 0px) !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 90% !important;
    max-width: 800px !important;
    z-index: 1000 !important;
    padding: 20px 0 !important;
    background: transparent !important;
}

.ios-device .input-wrapper,
body[data-platform="ios"] .input-wrapper {
    background: rgba(0, 0, 0, 0.25) !important;
    backdrop-filter: blur(0.5px) !important;
    -webkit-backdrop-filter: blur(0.5px) !important;
    border: 1px solid rgba(255, 255, 255, 0.03) !important;
    border-radius: 16px !important;
    padding: 12px !important;
}

/* iOS chat window positioning */
.ios-device #chat-window,
body[data-platform="ios"] #chat-window {
    bottom: 120px !important;
    max-height: calc(var(--real-vh, 1vh) * 40) !important;
}

/* Android Chrome specific fixes - Enhanced for proper input alignment */
@supports (-webkit-appearance: none) and (not (-ms-ime-align: auto)) and (not (-moz-appearance: none)) {
    /* Detect Android Chrome by user agent */
    .android-chrome .input-area,
    body[data-platform="android"] .input-area {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        transform: none !important;
        padding: 16px !important;
        background: rgba(0, 0, 0, 0.9) !important;
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        z-index: 9999 !important;
        max-width: none !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .android-chrome .input-wrapper,
    body[data-platform="android"] .input-wrapper {
        background: rgba(0, 0, 0, 0.25) !important;
        backdrop-filter: blur(0.5px) !important;
        -webkit-backdrop-filter: blur(0.5px) !important;
        border: 1px solid rgba(255, 255, 255, 0.03) !important;
        border-radius: 16px !important;
        padding: 12px !important;
        display: flex !important;
        align-items: flex-end !important;
        gap: 12px !important;
        position: relative !important;
    }

    /* Hide duplicate/unstyled elements on Android */
    .android-chrome input[type="file"]:not(#file-input),
    body[data-platform="android"] input[type="file"]:not(#file-input),
    .android-chrome button:not(.attach-btn):not(.mic-btn):not(.send-btn):not(.close-history),
    body[data-platform="android"] button:not(.attach-btn):not(.mic-btn):not(.send-btn):not(.close-history) {
        display: none !important;
        visibility: hidden !important;
    }

    /* Ensure chat history close button is visible on Android */
    .android-chrome .close-history,
    body[data-platform="android"] .close-history {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        -webkit-appearance: none !important;
        background: transparent !important;
        border: 1px solid rgba(159, 239, 0, 0.3) !important;
        color: #9fef00 !important;
        padding: 8px 12px !important;
        border-radius: 6px !important;
        cursor: pointer !important;
        font-size: 12px !important;
        touch-action: manipulation !important;
    }

    /* Aggressively hide the file input element on Android - prevent native UI from showing */
    .android-chrome #file-input,
    body[data-platform="android"] #file-input {
        position: absolute !important;
        left: -9999px !important;
        top: -9999px !important;
        width: 0 !important;
        height: 0 !important;
        opacity: 0 !important;
        visibility: hidden !important;
        display: none !important;
        pointer-events: none !important;
        z-index: -1000 !important;
    }

    /* Fix button alignment and sizing on Android */
    .android-chrome .attach-btn,
    .android-chrome .mic-btn,
    .android-chrome .send-btn,
    body[data-platform="android"] .attach-btn,
    body[data-platform="android"] .mic-btn,
    body[data-platform="android"] .send-btn {
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        background: rgba(15, 15, 15, 0.7) !important;
        border: 1px solid rgba(30, 30, 30, 0.5) !important;
        border-radius: 12px !important;
        padding: 10px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex-shrink: 0 !important;
        -webkit-appearance: none !important;
        -webkit-tap-highlight-color: transparent !important;
        touch-action: manipulation !important;
        position: relative !important;
        z-index: 1 !important;
    }

    /* Fix textarea on Android */
    .android-chrome .input-wrapper textarea,
    body[data-platform="android"] .input-wrapper textarea {
        flex: 1 !important;
        background: transparent !important;
        border: none !important;
        border-radius: 10px !important;
        color: rgba(255, 255, 255, 0.95) !important;
        font-family: inherit !important;
        font-size: 16px !important;
        resize: none !important;
        outline: none !important;
        min-height: 20px !important;
        max-height: 120px !important;
        line-height: 1.5 !important;
        padding: 10px 14px !important;
        overflow-y: auto !important;
        -webkit-appearance: none !important;
    }

    /* Input buttons container alignment */
    .android-chrome .input-buttons,
    body[data-platform="android"] .input-buttons {
        display: flex !important;
        gap: 8px !important;
        flex-shrink: 0 !important;
        align-items: center !important;
    }

    .android-chrome #live2d-container,
    body[data-platform="android"] #live2d-container {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        background-color: #000000 !important;
        background-image: url('background2.jpg') !important;
        background-size: cover !important;
        background-position: center center !important;
        background-repeat: no-repeat !important;
        z-index: 1 !important;
    }

    .android-chrome canvas,
    body[data-platform="android"] canvas {
        image-rendering: auto !important;
        -webkit-transform: translateZ(0) !important;
        transform: translateZ(0) !important;
        width: 100% !important;
        height: 100% !important;
    }
}


/* Desktop and non-mobile device protection */
@media screen and (min-width: 769px) and (hover: hover) and (pointer: fine) {
    /* Ensure desktop styles are preserved */
    .main-container {
        position: relative !important;
        width: 100vw !important;
        height: 100vh !important;
        max-width: 800px !important;
        margin: 0 auto !important;
    }
    
    .input-area {
        position: absolute !important;
        bottom: 20px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: 90% !important;
        max-width: 800px !important;
        z-index: 1000 !important;
    }
    
    body {
        position: static !important;
        height: 100vh !important;
        min-height: 100vh !important;
    }
    
    /* Override any mobile-specific classes that might leak to desktop */
    body.ios-device,
    body[data-platform="ios"],
    body.android-chrome,
    body[data-platform="android"] {
        position: static !important;
        height: 100vh !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
        transform: none !important;
    }

    .ios-device .main-container,
    body[data-platform="ios"] .main-container,
    .android-chrome .main-container,
    body[data-platform="android"] .main-container {
        position: relative !important;
        width: 100vw !important;
        height: 100vh !important;
        max-width: 800px !important;
        margin: 0 auto !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
        transform: none !important;
    }

    .ios-device .input-area,
    body[data-platform="ios"] .input-area,
    .android-chrome .input-area,
    body[data-platform="android"] .input-area {
        position: absolute !important;
        bottom: 20px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: 90% !important;
        max-width: 800px !important;
        padding: 0 !important;
        background: transparent !important;
    }
}

/* Force input area visibility on all mobile with enhanced specificity */
@media screen and (max-width: 768px), (hover: none) and (pointer: coarse) {
    /* Only apply mobile styles to actual mobile devices */
    .input-area:not(.desktop-override) {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: none !important;
        transform: none !important;
        z-index: 9999 !important;
        padding: 20px 15px !important;
        padding-bottom: calc(20px + env(safe-area-inset-bottom)) !important;
        background: transparent !important;
        backdrop-filter: blur(25px) !important;
        -webkit-backdrop-filter: blur(25px) !important;
        box-sizing: border-box !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        transition: all 0.3s ease !important;
    }
    
    .input-area:focus-within {
        background: transparent !important;
        backdrop-filter: blur(30px) !important;
        -webkit-backdrop-filter: blur(30px) !important;
    }
    
    .input-wrapper {
        background: rgba(0, 0, 0, 0.28) !important;
        backdrop-filter: blur(0.5px) !important;
        -webkit-backdrop-filter: blur(0.5px) !important;
        border: 1px solid rgba(255, 255, 255, 0.04) !important;
        border-radius: 20px !important;
        padding: 12px !important;
        gap: 12px !important;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18) !important;
    }
    
    .input-wrapper:focus-within {
        background: rgba(0, 0, 0, 0.38) !important;
        border: 1px solid rgba(255, 255, 255, 0.06) !important;
        box-shadow: 0 3px 15px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.04) !important;
    }
    
    .input-wrapper textarea {
        font-size: 16px !important; /* Prevents zoom on iOS */
        -webkit-appearance: none !important;
        padding: 10px 12px !important;
        min-height: 20px !important;
        background: transparent !important;
        border: none !important;
        border-radius: 10px !important;
        overflow-y: hidden !important;
        scrollbar-width: none !important;
        -ms-overflow-style: none !important;
    }
    
    .attach-btn,
    .mic-btn,
    .send-btn {
        min-width: 44px !important;
        min-height: 44px !important;
        width: 44px !important;
        height: 44px !important;
        border-radius: 12px !important;
        padding: 12px !important;
        background: rgba(15, 15, 15, 0.8) !important;
        border: 1px solid rgba(30, 30, 30, 0.6) !important;
        -webkit-appearance: none !important;
        -webkit-tap-highlight-color: transparent !important;
        touch-action: manipulation !important;
    }
    
    .attach-btn svg,
    .mic-btn svg,
    .send-btn svg {
        width: 18px !important;
        height: 18px !important;
    }
    
    .attach-btn:active,
    .mic-btn:active {
        transform: scale(0.95) !important;
        background: rgba(25, 25, 25, 0.9) !important;
        border-color: rgba(40, 40, 40, 0.8) !important;
    }
    
    .send-btn:active {
        transform: scale(0.95) !important;
        background: transparent !important;
        border-color: #6e66ff !important;
    }
    
    #chat-window {
        bottom: 130px !important;
        padding-bottom: 20px !important;
        max-height: calc(100vh - 250px) !important;
        max-height: calc(100dvh - 250px) !important;
        max-height: calc(var(--real-vh, 100vh) - 250px) !important;
    }
    
    #attachment-preview {
        bottom: 105px !important;
        left: 50% !important;
        transform: translateX(-50%) translateX(-30%) !important;
        max-width: 250px !important;
        padding: 10px !important;
        border-radius: 10px !important;
        background: rgba(0, 0, 0, 0.06) !important;
        backdrop-filter: blur(8px) !important;
        -webkit-backdrop-filter: blur(8px) !important;
        border: none !important;
    }
    
    #live2d-container canvas {
        width: 100% !important;
        height: 100% !important;
        display: block !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
    }
}

/* Handle virtual keyboard on mobile - prevent viewport resize */
.keyboard-visible {
    height: 100vh !important;
    max-height: 100vh !important;
    overflow: hidden !important;
}

.keyboard-visible .main-container {
    height: 100vh !important;
    position: fixed !important;
    top: 0 !important;
    width: 100% !important;
}

.keyboard-visible #live2d-container {
    height: 100vh !important;
    position: relative !important;
}

.keyboard-visible .input-area {
    position: fixed !important;
    bottom: 0 !important;
    z-index: 1000 !important;
}

.keyboard-visible #chat-window {
    max-height: 30vh !important;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .main-container {
        width: 95%;
        margin-top: 10px;
    }

    #live2d-container {
        height: 300px;
    }

    .message {
        max-width: 85%;
    }

    .header-bar {
        padding: 15px;
    }

    .header-title {
        font-size: 1em;
    }

    #chat-window {
        bottom: 120px;
        width: 95%;
    }
}

/* Loading indicator styles */
.loading-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

.pulse-indicator {
    width: 12px;
    height: 12px;
    background: #00ff88;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

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

/* WAIFUX Loading Screen Styles */
.waifux-logo {
    text-align: center;
    margin-bottom: 30px;
}

.waifux-logo img {
    max-width: 300px;
    height: auto;
    opacity: 0.9;
}

.hud {
    width: 420px;
    margin: 0 auto;
    z-index: 10;
    position: relative;
    text-align: center;
}

.bar-container {
    width: 300px;
    height: 12px;
    background: rgba(255, 105, 180, 0.1);
    position: relative;
    overflow: visible;
    border-radius: 20px;
}

.bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #ff69b4 0%, #ff1493 100%);
    box-shadow: 0 0 15px rgba(255, 105, 180, 0.8);
    transition: width 0.12s linear;
    position: relative;
    border-radius: 20px;
}

.waifu-icon {
    position: absolute;
    right: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    filter: brightness(0) invert(1);
}


.percent {
    text-align: center;
    margin-top: 10px;
    font-size: 14px;
    letter-spacing: 1px;
    color: #ff69b4;
    text-shadow: 0 0 5px rgba(255, 105, 180, 0.5);
}

.copyright {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: #888;
    opacity: 0.7;
}