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

body {
    background: #0a0a0f;
    color: #e0e0e0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#app {
    text-align: center;
    width: 100%;
}

#orb-container {
    cursor: pointer;
    display: inline-block;
    margin-bottom: 40px;
}

#orb {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    transition: all 0.4s ease;
}

#orb.idle {
    background: radial-gradient(circle at 40% 40%, #1a3a5c, #0d1b2a);
    box-shadow: 0 0 40px rgba(30, 90, 160, 0.3), 0 0 80px rgba(30, 90, 160, 0.1);
}

#orb.listening {
    background: radial-gradient(circle at 40% 40%, #2a6cb8, #1a3a5c);
    box-shadow: 0 0 60px rgba(42, 108, 184, 0.6), 0 0 120px rgba(42, 108, 184, 0.2);
    animation: pulse-listen 1.5s ease-in-out infinite;
}

#orb.thinking {
    background: radial-gradient(circle at 40% 40%, #c9a227, #8b6914);
    box-shadow: 0 0 60px rgba(201, 162, 39, 0.5), 0 0 120px rgba(201, 162, 39, 0.15);
    animation: pulse-think 0.8s ease-in-out infinite;
}

#orb.speaking {
    background: radial-gradient(circle at 40% 40%, #27c96a, #148b3d);
    box-shadow: 0 0 60px rgba(39, 201, 106, 0.6), 0 0 120px rgba(39, 201, 106, 0.2);
    animation: pulse-speak 0.6s ease-in-out infinite;
}

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

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

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

#status {
    font-size: 14px;
    color: #666;
    margin-bottom: 20px;
    min-height: 20px;
}

#transcript {
    max-width: 600px;
    margin: 0 auto;
    text-align: left;
    max-height: 300px;
    overflow-y: auto;
    padding: 0 20px;
}

#transcript .user {
    color: #888;
    margin-bottom: 8px;
    font-size: 13px;
}

#transcript .jarvis {
    color: #4a9eff;
    margin-bottom: 16px;
    font-size: 14px;
}

#chat-form {
    width: 100%;
    max-width: 600px;
    margin: 20px auto 0 auto;
    padding: 0 20px calc(20px + env(safe-area-inset-bottom, 0px)) 20px;
    display: flex;
    gap: 8px;
    align-items: center;
    box-sizing: border-box;
}

#chat-input {
    flex: 1;
    min-width: 0;
    background: #14141c;
    border: 1px solid #2a2a38;
    color: #e0e0e0;
    font-family: inherit;
    font-size: 16px;
    padding: 12px 16px;
    border-radius: 24px;
    outline: none;
    transition: border-color 0.2s ease, background 0.2s ease;
    /* Prevent iOS auto-zoom on focus: font-size must be >= 16px */
    -webkit-appearance: none;
}

#chat-input::placeholder {
    color: #555;
}

#chat-input:focus {
    border-color: #4a9eff;
    background: #181822;
}

#chat-send {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: #1a3a5c;
    color: #e0e0e0;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#chat-send:hover {
    background: #2a6cb8;
}

#chat-send:active {
    transform: scale(0.92);
}

#chat-send:disabled {
    background: #14141c;
    color: #444;
    cursor: not-allowed;
}

/* On narrow screens (iPhone, home-screen Web App), give each section
   its own slot in a flex column so:
     - The orb is vertically centered in the hero area (flex:1)
     - The transcript has a bounded, scrollable area below
     - The chat form pins to the bottom over the safe-area inset
   Body is flex row + justify-content:center by default, which
   content-sizes its children along the horizontal axis even with
   width:100%. Flip body to column on mobile so the cross axis is
   horizontal and align-items:stretch genuinely fills 100vw.
   Use 100dvh (dynamic viewport height) so the layout adapts when
   the iOS keyboard opens and the viewport shrinks. */
@media (max-width: 700px) {
    body {
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
    }
    #app {
        display: flex;
        flex-direction: column;
        width: 100%;
        min-height: 100vh;
        min-height: 100dvh;
        padding-top: env(safe-area-inset-top, 0px);
    }
    #orb-container {
        flex: 1;
        min-height: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-bottom: 0;
        /* override base inline-block */
    }
    #status {
        flex-shrink: 0;
    }
    #transcript {
        flex-shrink: 0;
        max-width: none;
        max-height: 30vh;
        overflow-y: auto;
    }
    #chat-form {
        flex-shrink: 0;
        margin-top: 12px;
        width: 100%;
        max-width: none;
    }
    #chat-input {
        width: auto;
    }
}
