:root {
    --bg-primary: #000; /* True black for OLED effect */
    --bg-secondary: #000; /* Use true black for elements that were slightly darker */
    --text-primary: #e8eaed;
    --text-secondary: #9aa0a6;
    --accent-color: #bb86fc; /* A modern purple accent for dark themes */
    --hover-color: #1a1a1a; /* Slightly less dark hover color to be visible on true black */
    --container-bg: #000; /* Background for the main container - true black */
    --border-color: #333; /* Slightly visible border */
}

body {
    font-family: 'Inter', Arial, sans-serif;
    background-image: url('background-abstract.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    backdrop-filter: brightness(0.7) blur(5px);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    box-sizing: border-box;
    background-repeat: no-repeat;
}

.container {
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(187, 134, 252, 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transition: all 0.5s ease;
    border-radius: 24px;
    box-shadow: none; /* Remove shadow for a flatter, true black look */
    width: 100%;
    max-width: 600px;
    padding: 30px;
    text-align: center;
    box-sizing: border-box;
    display: flex; /* Use flexbox for layout control */
    flex-direction: column;
    align-items: center;
}

/* State when AI response is active */
.container.ai-active {
    justify-content: flex-start; /* Align items to the top */
    min-height: 100vh; /* Ensure it takes full viewport height */
}

.logo {
    font-size: 28px; /* Slightly larger logo */
    font-weight: 600;
    margin-bottom: 40px; /* More space below logo */
    color: var(--text-primary);
    text-shadow: 0 0 10px rgba(187, 134, 252, 0.3); /* Subtle glow effect */
    transition: margin-bottom 0.5s ease; /* Smooth transition */
}

.container.ai-active .logo {
    margin-top: 20px; /* Push logo down slightly from the very top */
    margin-bottom: 20px; /* Reduce margin below logo in AI mode */
}

.search-wrapper {
    margin-bottom: 30px;
    width: 100%; /* Ensure search wrapper takes full width */
    transition: margin-bottom 0.5s ease; /* Smooth transition */
}

.container.ai-active .search-wrapper {
    margin-bottom: 15px; /* Reduce margin below search in AI mode */
}

.search-input-container {
    position: relative;
    width: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    border-radius: 24px;
}

#search-input {
    width: 100%;
    padding: 15px 45px 15px 20px;
    font-size: 18px;
    border: 1px solid rgba(187, 134, 252, 0.2);
    border-radius: 24px;
    background-color: transparent;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease, opacity 0.5s ease;
    box-sizing: border-box;
    line-height: 1.5;
    height: auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    position: relative;
}

#search-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 8px rgba(187, 134, 252, 0.5);
}

#search-button {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: color 0.3s ease, background-color 0.3s ease;
    display: flex; /* Use flexbox to center the icon */
    align-items: center;
    justify-content: center;
}

#search-button:hover {
    color: var(--text-primary);
    background-color: var(--hover-color);
}

/* Style for Phosphor Icon */
#search-button .ph {
    font-size: 20px; /* Set icon size */
    display: block; /* Ensure display block */
}

.search-engines-scroll {
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    padding: 10px 0;
    margin: 0 -30px;
    padding-left: 30px;
    padding-right: 30px;
    position: relative; /* Needed for gradient overlay positioning */
    width: calc(100% + 60px); /* Match container padding */
    box-sizing: border-box;
    transition: all 0.5s ease; /* Smooth transition */
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
}

.container.ai-active .search-engines-scroll {
    margin-bottom: 20px; /* Add space below engines in AI mode */
}

.search-engines {
    display: inline-flex;
    gap: 20px;
    align-items: center;
    padding-bottom: 10px;
    /* Allow content to extend beyond container width */
    width: max-content;
}

.search-engine {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 12px;
    transition: all 0.3s ease;
    min-width: unset;
}

.search-engine span {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
    white-space: nowrap;
}

.search-engine:hover {
    background-color: var(--hover-color);
}

.search-engine.selected {
    background-color: var(--accent-color);
    box-shadow: none;
}

.search-engine.selected span {
    color: var(--text-primary);
    font-weight: 600;
}

/* Gradient Overlay for Scroll Hint */
.scroll-gradient {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 60px; /* Width of the gradient */
    background: linear-gradient(to right, rgba(0, 0, 0, 0), var(--bg-primary)); /* Fade from transparent to background color */
    pointer-events: none; /* Allow clicks/touches to pass through */
    z-index: 1; /* Ensure it's above the content but below the container */
}

.search-engines-scroll::-webkit-scrollbar {
    display: none;
}

.search-engines-scroll {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* AI Response Area Styles */
.ai-response-area {
    width: 100%;
    text-align: left;
    margin-top: 0; /* No margin initially */
    opacity: 0; /* Hidden initially */
    max-height: 0; /* Collapse height initially */
    overflow: hidden; /* Hide content overflow */
    transition: opacity 0.5s ease, max-height 0.5s ease, margin-top 0.5s ease; /* Smooth transition */
}

.container.ai-active .ai-response-area {
    opacity: 1; /* Show when active */
    max-height: 80vh; /* Allow it to grow, adjust as needed */
    margin-top: 20px; /* Add space above the response */
    overflow-y: auto; /* Allow scrolling within the response area */
}

.ai-response-content {
    padding: 15px;
    border-radius: 12px;
    background-color: transparent; /* Keep transparent background */
    border: 1px solid transparent; /* Make border almost invisible */
    color: var(--text-primary);
    word-wrap: break-word;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); /* Subtle shadow for depth */
}

.ai-response-content a {
    color: var(--accent-color);
    text-decoration: underline;
    transition: color 0.3s ease;
}

.ai-response-content a:hover {
    color: var(--text-primary);
}

/* Markdown Basic Styles */
.ai-response-content h1, .ai-response-content h2, .ai-response-content h3,
.ai-response-content h4, .ai-response-content h5, .ai-response-content h6 {
    color: var(--accent-color);
    margin-top: 1em;
    margin-bottom: 0.5em;
}

.ai-response-content p {
    margin-bottom: 1em;
    line-height: 1.6;
}

.ai-response-content code {
    background-color: var(--bg-secondary);
    padding: 2px 4px;
    border-radius: 4px;
    font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
}

.ai-response-content pre {
    background-color: var(--bg-secondary);
    padding: 10px;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1em;
}

.ai-response-content pre code {
    padding: 0;
    border-radius: 0;
    background-color: transparent;
}

.ai-response-content strong {
    color: var(--text-primary);
}

.ai-response-content em {
    font-style: italic;
}

.ai-response-content blockquote {
    border-left: 4px solid var(--accent-color);
    padding-left: 10px;
    margin-left: 0;
    color: var(--text-secondary);
    font-style: italic;
}

.ai-response-content ul, .ai-response-content ol {
    list-style: none;
    padding-left: 20px;
}

.ai-response-content ol {
    counter-reset: item;
}

.ai-response-content ul {
    counter-reset: list-item;
}

.ai-response-content ol > li {
    counter-increment: item;
    position: relative;
    margin-bottom: 0.5em;
}

.ai-response-content ol > li::before {
    content: "Item " counter(item) " of the list"; 
    position: absolute;
    left: -100px; 
    color: var(--text-secondary);
    font-weight: bold;
    speak: normal;
    width: 100px;
    text-align: right;
    padding-right: 10px;
}

.ai-response-content ul > li {
    position: relative;
    margin-bottom: 0.5em;
    padding-left: 20px;
}

.ai-response-content ul > li::before {
    content: "•"; 
    position: absolute;
    left: 0;
    color: var(--text-primary);
}

.ai-response-content ul > li::marker {
    content: none; 
}

.ai-response-content ul > li {
    counter-increment: list-item;
    position: relative;
    margin-bottom: 0.5em;
}

.ai-response-content ul > li::before {
    content: "•"; 
    position: absolute;
    left: 0;
    color: var(--text-primary);
}

.ai-response-content li {
    margin-bottom: 0.5em;
}

.ai-response-content li:hover {
    background-color: rgba(255, 255, 255, 0.05);
    transition: background-color 0.3s ease;
}

/* AI Loading Indicator Styles */
.ai-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: var(--text-secondary);
    text-align: center;
}

.ai-loading .spinner {
    display: inline-block;
    position: relative;
    width: 30px; /* Size of the spinner area */
    height: 30px; /* Size of the spinner area */
    margin-bottom: 10px;
}

.ai-loading .spinner .ph-sparkle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px; /* Size of the sparkle icon */
    color: var(--accent-color); /* Color of the sparkle */
    animation: sparkle-spin 1.5s linear infinite; /* Animation */
}

@keyframes sparkle-spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes marquee {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(calc(-100% + 100%)); /* Adjust to ensure smooth scroll */
    }
}

.search-input-text {
    display: inline-block;
    white-space: nowrap;
}

.search-input-text.marquee {
    animation: marquee 10s linear infinite;
    animation-play-state: paused;
}

.search-input-text.marquee:hover {
    animation-play-state: running;
}

/* Initially hide loading and content */
.ai-loading, .ai-response-content {
    display: none;
}

/* Show loading when active and response is empty */
.container.ai-active .ai-loading {
    display: flex; /* Show flexbox */
}

/* Hide loading when response content is shown */
.container.ai-active .ai-response-content:not(:empty) + .ai-loading {
    display: none;
}

.container.ai-active .ai-loading + .ai-response-content:not(:empty) {
    display: block; /* Show response content when it's not empty */
}

/* Quick Shortcuts Styles */
.quick-shortcuts {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 20px;
    padding: 10px;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
}

.quick-shortcut {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.7;
}

.quick-shortcut:hover {
    opacity: 1;
    transform: scale(1.1);
}

.quick-shortcut i {
    font-size: 24px;
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.quick-shortcut:hover i {
    color: var(--text-primary);
}

.quick-shortcut span {
    margin-top: 5px;
    font-size: 12px;
    color: var(--text-secondary);
}

.show-more-container {
    display: none;
}

.expanded-menu {
    display: none;
}

/* Instructions Section Styles */
.instructions-container {
    width: 100%;
    margin-top: 20px;
    text-align: center;
}

.instructions {
    font-size: 14px;
    color: var(--text-secondary);
    opacity: 1;
    transition: opacity 0.5s ease;
}

.instructions.fade-out {
    opacity: 0;
}

/* Mobile Adjustments */
@media (max-width: 600px) {
    body {
        padding: 0;
        background-size: cover;
        background-position: center;
        min-height: 100vh; /* Ensure full height */
        align-items: stretch; /* Stretch to fill height */
    }

    .container {
        width: 100%;
        margin: 0;
        padding: 20px;
        border-radius: 0;
        min-height: 100vh;
        background-color: rgba(0, 0, 0, 0.8);
        display: flex;
        flex-direction: column;
        justify-content: center;
        flex-grow: 1; /* Allow container to grow */
    }

    .container.ai-active {
        justify-content: flex-start;
    }

    .logo {
        font-size: 24px;
        margin-bottom: 30px;
    }

    .container.ai-active .logo {
        margin-top: 10px;
        margin-bottom: 15px;
    }

    .search-wrapper {
        margin-bottom: 20px;
    }

    .container.ai-active .search-wrapper {
        margin-bottom: 10px;
    }

    #search-input {
        font-size: 16px;
        padding: 12px 40px 12px 15px;
    }

    #search-button {
        right: 5px;
        padding: 5px;
    }

    #search-button .ph {
        width: 18px;
        height: 18px;
        font-size: 18px;
    }

    .search-engines-scroll {
        margin: 0 -20px;
        padding-left: 20px;
        padding-right: 20px;
        padding-bottom: 10px;
        width: calc(100% + 40px); /* Match container padding */
    }

    .container.ai-active .search-engines-scroll {
        margin-bottom: 15px;
    }

    .search-engines {
        gap: 15px;
    }

    .search-engine span {
        font-size: 12px;
    }

    .scroll-gradient {
        width: 40px; /* Smaller width on mobile */
    }

    .ai-response-area {
        flex-grow: 1; /* Allow response area to take available space */
        display: flex; /* Use flex to handle internal layout */
        flex-direction: column;
    }

    .container.ai-active .ai-response-area {
        margin-top: 15px;
        max-height: unset; /* Allow full height */
        overflow-y: auto; /* Allow scrolling within the response area */
    }

    .ai-loading {
        flex-grow: 1; /* Allow loading to take space */
    }

    .ai-response-content {
        flex-grow: 1; /* Allow content to take space */
    }

    .quick-shortcuts {
        gap: 15px;
        margin-top: 15px;
    }

    .quick-shortcut i {
        font-size: 20px;
    }

    .quick-shortcut span {
        font-size: 10px;
    }

    .instructions {
        font-size: 12px;
    }
}

@media (max-width: 600px) {
}