#erva-widget-container,
#erva-widget-container * {
    box-sizing: border-box;
}

#erva-widget-container {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#erva-widget-container button,
#erva-widget-container input {
    font: inherit;
}

#erva-widget-container svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: 0 0 auto;
}

#erva-widget-container .erva-hidden {
    display: none !important;
}

#erva-fab {
    width: 62px;
    height: 62px;
    border: 0;
    border-radius: 999px;
    background: #2563eb;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
    cursor: pointer;
}

#erva-fab:hover,
#erva-fab:focus-visible {
    background: #1d4ed8;
}

#erva-chat-panel {
    width: min(380px, calc(100vw - 20px));
    height: min(580px, calc(100vh - 24px));
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
}

#erva-widget-container .erva-panel-header {
    background: #2563eb;
    color: #fff;
    padding: 14px 14px 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

#erva-widget-container .erva-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 16px;
}

#erva-close-btn {
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #fff;
    cursor: pointer;
}

#erva-close-btn:hover,
#erva-close-btn:focus-visible {
    background: rgba(255, 255, 255, 0.14);
}

#erva-chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#erva-widget-container .erva-message {
    max-width: 88%;
    padding: 11px 13px;
    border-radius: 14px;
    line-height: 1.45;
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
}

#erva-widget-container .erva-agent {
    align-self: flex-start;
    background: #fff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
}

#erva-widget-container .erva-thinking {
    min-width: 74px;
    padding: 12px 14px;
}

#erva-widget-container .erva-thinking-dots {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 14px;
}

#erva-widget-container .erva-thinking-dots span {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #94a3b8;
    display: block;
    animation: ervaThinkingBounce 1.1s infinite ease-in-out;
}

#erva-widget-container .erva-thinking-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

#erva-widget-container .erva-thinking-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

#erva-widget-container .erva-user {
    align-self: flex-end;
    background: #2563eb;
    color: #fff;
}

#erva-widget-container .erva-system {
    align-self: center;
    width: 100%;
    max-width: 100%;
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    font-size: 12px;
}

#erva-status-indicator {
    padding: 8px 14px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 12px;
    border-top: 1px solid #dbeafe;
}

#erva-widget-container .erva-panel-footer {
    padding: 12px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
}

#erva-widget-container .erva-input-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

#erva-text-input {
    flex: 1;
    min-width: 0;
    height: 46px;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 0 14px;
    outline: none;
    background: #fff;
    color: #0f172a;
}

#erva-text-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

#erva-send-btn,
#erva-record-btn {
    border: 0;
    cursor: pointer;
}

#erva-send-btn {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: #2563eb;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

#erva-send-btn:hover,
#erva-send-btn:focus-visible {
    background: #1d4ed8;
}

#erva-record-btn {
    width: 100%;
    margin-top: 10px;
    min-height: 48px;
    padding: 12px 14px;
    border-radius: 12px;
    background: #f8fafc;
    color: #0f172a;
    border: 1px solid #cbd5e1;
}

#erva-widget-container .erva-btn-inner {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

#erva-record-btn:hover,
#erva-record-btn:focus-visible {
    background: #f1f5f9;
}

#erva-record-btn.erva-recording {
    background: #ef4444;
    border-color: #ef4444;
    color: #fff;
}

#erva-send-btn:disabled,
#erva-record-btn:disabled,
#erva-text-input:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

#erva-widget-container .erva-footer-note {
    margin-top: 8px;
    color: #64748b;
    font-size: 12px;
    line-height: 1.35;
}

@media (max-width: 640px) {
    #erva-widget-container {
        right: 8px;
        bottom: 8px;
    }

    #erva-chat-panel {
        width: calc(100vw - 16px);
        height: min(78vh, calc(100vh - 16px));
        border-radius: 14px;
    }

    #erva-widget-container .erva-message {
        max-width: 92%;
    }
}


@keyframes ervaThinkingBounce {
    0%, 80%, 100% {
        transform: translateY(0);
        opacity: 0.45;
    }
    40% {
        transform: translateY(-4px);
        opacity: 1;
    }
}
