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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #000000;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: hidden;
}

/* Subtle visual effects */
.scanlines {
    display: none;
}

.noise {
    display: none;
}

.vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    z-index: 997;
}

.container {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    overflow: hidden;
}

#canvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Q&A Interface */
.qa-container {
    position: absolute;
    top: 72%;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 800px;
    z-index: 3;
    opacity: 0;
    transition: opacity 1s ease-out 1s;
}

.qa-container.active {
    opacity: 1;
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 20px;
    justify-content: center;
}

.prompt-text {
    color: rgba(255, 255, 255, 0.6);
    font-size: 1rem;
    font-weight: 300;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.5px;
    white-space: nowrap;
    margin-right: 8px;
}

#question-input {
    background: transparent;
    border: none;
    outline: none;
    color: rgba(255, 255, 255, 0.8);
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    font-weight: 300;
    letter-spacing: 0.5px;
    padding: 0;
    width: auto;
    min-width: 20px;
    max-width: 500px;
    caret-color: rgba(255, 255, 255, 0.8);
    /* Prevent zoom on mobile when focusing */
    touch-action: manipulation;
}

#question-input::placeholder {
    color: transparent;
}

#question-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Prevent iOS zoom on input focus */
@supports (-webkit-touch-callout: none) {
    #question-input {
        font-size: 16px;
    }
}

.loading {
    display: none;
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    margin-bottom: 15px;
}

.loading::after {
    content: '...';
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

.response-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: visible;
    margin-top: 0;
}

.qa-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.qa-item .question-line {
    color: rgba(255, 255, 255, 0.8);
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    opacity: 0;
    transform: translateY(-80px);
    transition: all 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.qa-item .question-line.slide-in {
    opacity: 1;
    transform: translateY(0);
}

.qa-item .answer-line {
    color: rgba(255, 255, 255, 0.9);
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    padding-left: 15px;
    opacity: 0;
    transform: translateY(-30px);
    transition: all 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.qa-item .answer-line.slide-in {
    opacity: 1;
    transform: translateY(0);
}

/* Fade out older items progressively */
.qa-item.fade-out {
    opacity: 0;
    transform: translateY(-20px);
    max-height: 0;
    margin: 0;
    transition: all 0.8s ease-out;
}

.qa-item.error .answer-line {
    color: rgba(255, 120, 120, 0.9);
}

@media (max-width: 768px) {
    #canvas {
        /* Don't constrain canvas with CSS - it distorts the aspect ratio */
    }

    .qa-container {
        width: 100%;
        top: auto;
        bottom: 20px;
        max-width: 100vw;
        transform: translateX(-50%);
        padding: 0 5%;
        box-sizing: border-box;
    }

    .input-wrapper {
        flex-direction: column;
        align-items: flex-start;
        justify-content: flex-start;
        padding: 0;
        gap: 8px;
        width: 100%;
        box-sizing: border-box;
        position: relative;
        z-index: 10;
    }

    .prompt-text {
        font-size: 1.1rem;
        margin-bottom: 0;
        margin-right: 0;
        width: 100%;
        text-align: left;
        word-wrap: break-word;
    }

    #question-input {
        font-size: 16px !important; /* Prevent iOS zoom */
        max-width: 100%;
        width: 100%;
        margin-left: 0;
        padding: 8px 0;
        min-height: 24px;
        box-sizing: border-box;
    }

    .response-container {
        font-size: 0.9rem;
        width: 100%;
        box-sizing: border-box;
        gap: 10px;
        position: absolute;
        bottom: 100%;
        left: 0;
        right: 0;
        padding-bottom: 15px;
        flex-direction: column-reverse;
        max-height: 40vh;
        overflow: hidden;
        mask-image: linear-gradient(to bottom, transparent 0%, black 15%, black 100%);
        -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 15%, black 100%);
    }

    .qa-item .question-line,
    .qa-item .answer-line {
        font-size: 0.85rem;
        line-height: 1.5;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .qa-item .answer-line {
        padding-left: 10px;
    }

    .loading {
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    #canvas {
        /* Don't constrain canvas with CSS - it distorts the aspect ratio */
    }

    .qa-container {
        width: 100%;
        bottom: 15px;
        padding: 0 5%;
    }

    .input-wrapper {
        padding: 0;
        width: 100%;
    }

    .prompt-text {
        font-size: 1rem;
    }

    #question-input {
        font-size: 16px !important;
    }

    .response-container {
        width: 100%;
        gap: 8px;
        position: absolute;
        bottom: 100%;
        left: 0;
        right: 0;
        padding-bottom: 12px;
        flex-direction: column-reverse;
        max-height: 35vh;
        overflow: hidden;
        mask-image: linear-gradient(to bottom, transparent 0%, black 15%, black 100%);
        -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 15%, black 100%);
    }

    .qa-item .question-line,
    .qa-item .answer-line {
        font-size: 0.8rem;
        line-height: 1.4;
    }

    .qa-item .answer-line {
        padding-left: 8px;
    }
}

/* Three.js Sphere Intro */
.sphere-intro {
    position: fixed;
    inset: 0;
    background-image: linear-gradient(to bottom left, #000, #011, #303);
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    animation: fadeIn 1s ease-out forwards;
    transition: background 1.5s ease-out, z-index 0s 1.5s;
}

.sphere-intro.moved-to-corner {
    background: transparent;
    z-index: 1; /* Lower z-index so content appears on top */
}

.sphere-intro canvas {
    display: block;
    width: 100%;
    height: 100%;
}

@keyframes fadeIn {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}
