/* ── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: #0a0a0a;
    color: #e0e0e0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    height: 100dvh;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

#app {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100dvh;
    position: relative;
}

/* ── Orb ────────────────────────────────────────────────── */
#orb-container {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

#orb {
    position: relative;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

#orb:active {
    transform: scale(0.95);
}

.orb-inner {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%,
        rgba(120, 120, 180, 0.8) 0%,
        rgba(60, 60, 120, 0.6) 40%,
        rgba(30, 30, 60, 0.4) 70%,
        rgba(10, 10, 30, 0.2) 100%);
    z-index: 2;
}

.orb-glow {
    position: absolute;
    inset: -20px;
    border-radius: 50%;
    z-index: 1;
    filter: blur(20px);
    opacity: 0.6;
    transition: background 0.5s ease, opacity 0.5s ease;
}

.orb-ring {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.08);
    z-index: 3;
    transition: border-color 0.5s ease;
}

/* ── Idle / Breathing ───────────────────────────────────── */
#orb.idle .orb-glow {
    background: radial-gradient(circle, rgba(100, 100, 180, 0.4), transparent 70%);
    animation: breathe 4s ease-in-out infinite;
}
#orb.idle .orb-inner {
    animation: breathe-inner 4s ease-in-out infinite;
}

@keyframes breathe {
    0%, 100% { transform: scale(1); opacity: 0.4; }
    50% { transform: scale(1.1); opacity: 0.7; }
}
@keyframes breathe-inner {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

/* ── Listening (user speaking) ──────────────────────────── */
#orb.listening .orb-glow {
    background: radial-gradient(circle, rgba(60, 130, 255, 0.6), transparent 70%);
    animation: listen-pulse 1.2s ease-in-out infinite;
}
#orb.listening .orb-inner {
    background: radial-gradient(circle at 40% 35%,
        rgba(80, 160, 255, 0.9) 0%,
        rgba(40, 100, 200, 0.7) 40%,
        rgba(20, 60, 140, 0.4) 70%,
        rgba(10, 30, 80, 0.2) 100%);
    animation: listen-inner 1.2s ease-in-out infinite;
}
#orb.listening .orb-ring {
    border-color: rgba(60, 130, 255, 0.3);
}

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

/* ── Thinking (processing tool call) ────────────────────── */
#orb.thinking .orb-glow {
    background: radial-gradient(circle, rgba(255, 180, 40, 0.5), transparent 70%);
    animation: think-spin 2s linear infinite;
}
#orb.thinking .orb-inner {
    background: radial-gradient(circle at 40% 35%,
        rgba(255, 200, 80, 0.8) 0%,
        rgba(200, 140, 40, 0.6) 40%,
        rgba(120, 80, 20, 0.3) 70%,
        rgba(60, 40, 10, 0.15) 100%);
    animation: breathe-inner 1.5s ease-in-out infinite;
}
#orb.thinking .orb-ring {
    border-color: rgba(255, 180, 40, 0.3);
    animation: ring-spin 3s linear infinite;
}

@keyframes think-spin {
    0% { transform: scale(1) rotate(0deg); opacity: 0.5; }
    50% { transform: scale(1.15) rotate(180deg); opacity: 0.7; }
    100% { transform: scale(1) rotate(360deg); opacity: 0.5; }
}
@keyframes ring-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ── Responding (AI speaking) ───────────────────────────── */
#orb.responding .orb-glow {
    background: radial-gradient(circle, rgba(40, 200, 120, 0.6), transparent 70%);
    animation: respond-pulse 0.8s ease-in-out infinite;
}
#orb.responding .orb-inner {
    background: radial-gradient(circle at 40% 35%,
        rgba(60, 220, 140, 0.9) 0%,
        rgba(30, 160, 100, 0.7) 40%,
        rgba(15, 100, 60, 0.4) 70%,
        rgba(5, 50, 30, 0.2) 100%);
    animation: respond-inner 0.8s ease-in-out infinite;
}
#orb.responding .orb-ring {
    border-color: rgba(40, 200, 120, 0.3);
}

@keyframes respond-pulse {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.3); opacity: 0.9; }
}
@keyframes respond-inner {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}

/* ── Disconnected ───────────────────────────────────────── */
#orb.disconnected .orb-glow {
    background: radial-gradient(circle, rgba(100, 100, 100, 0.2), transparent 70%);
    animation: none;
    opacity: 0.3;
}
#orb.disconnected .orb-inner {
    background: radial-gradient(circle at 40% 35%,
        rgba(80, 80, 80, 0.6) 0%,
        rgba(50, 50, 50, 0.4) 40%,
        rgba(30, 30, 30, 0.2) 70%,
        rgba(15, 15, 15, 0.1) 100%);
    animation: none;
}
#orb.disconnected .orb-ring {
    border-color: rgba(100, 100, 100, 0.1);
}

/* ── Status Text ────────────────────────────────────────── */
#status-text {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.5);
    margin-top: -40px;
    margin-bottom: 20px;
    text-align: center;
    transition: color 0.3s ease;
    letter-spacing: 0.5px;
}

/* ── Transcript ─────────────────────────────────────────── */
#transcript-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 30vh;
    overflow-y: auto;
    background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.85) 20%);
    padding: 30px 16px 20px;
    -webkit-overflow-scrolling: touch;
}

#transcript {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 600px;
    margin: 0 auto;
}

.msg {
    padding: 8px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
    max-width: 85%;
    word-break: break-word;
    animation: msg-in 0.3s ease-out;
}

.msg.user {
    align-self: flex-end;
    background: rgba(60, 130, 255, 0.2);
    border: 1px solid rgba(60, 130, 255, 0.15);
    color: rgba(255, 255, 255, 0.85);
    border-bottom-right-radius: 4px;
}

.msg.assistant {
    align-self: flex-start;
    background: rgba(40, 200, 120, 0.15);
    border: 1px solid rgba(40, 200, 120, 0.12);
    color: rgba(255, 255, 255, 0.85);
    border-bottom-left-radius: 4px;
}

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

/* ── Scrollbar ──────────────────────────────────────────── */
#transcript-container::-webkit-scrollbar { width: 4px; }
#transcript-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}
#transcript-container::-webkit-scrollbar-track { background: transparent; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 480px) {
    #orb {
        width: 130px;
        height: 130px;
    }
    .orb-glow { inset: -15px; }
    .orb-ring { inset: -3px; }
    #status-text { font-size: 14px; }
    .msg { font-size: 13px; }
}

@media (min-width: 768px) {
    #orb {
        width: 180px;
        height: 180px;
    }
    .orb-glow { inset: -30px; }
}
