:root { --aicb-primary: #6366f1; }

.aicb-chatbot, .aicb-chatbot * {
    box-sizing: border-box; margin: 0; padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", Meiryo, sans-serif;
}
.aicb-chatbot { position: fixed; bottom: 24px; z-index: 999999; }
.aicb-position-right { right: 24px; }
.aicb-position-left { left: 24px; }

.aicb-toggle {
    width: 60px; height: 60px; border-radius: 50%; background: var(--aicb-primary); color: #fff;
    border: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2); transition: transform .2s, box-shadow .2s;
    position: absolute; bottom: 0;
}
.aicb-position-right .aicb-toggle { right: 0; }
.aicb-position-left .aicb-toggle { left: 0; }
.aicb-toggle:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(0,0,0,0.25); }

.aicb-window {
    width: 380px; max-width: calc(100vw - 48px); height: 520px; max-height: calc(100vh - 120px);
    background: #fff; border-radius: 16px; box-shadow: 0 8px 40px rgba(0,0,0,0.15);
    display: flex; flex-direction: column; overflow: hidden; position: absolute; bottom: 76px;
    animation: aicb-slide-up .25s ease-out;
}
.aicb-position-right .aicb-window { right: 0; }
.aicb-position-left .aicb-window { left: 0; }

@keyframes aicb-slide-up {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.aicb-header {
    background: var(--aicb-primary); color: #fff; padding: 16px 18px;
    display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.aicb-header-info { display: flex; align-items: center; gap: 12px; }
.aicb-avatar {
    width: 38px; height: 38px; border-radius: 50%; background: rgba(255,255,255,0.2);
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
    overflow: hidden; flex-shrink: 0;
}
.aicb-header-name { font-weight: 600; font-size: 15px; }
.aicb-header-status { font-size: 12px; opacity: 0.8; }
.aicb-close-btn {
    background: none; border: none; color: #fff; font-size: 24px; cursor: pointer;
    padding: 4px 8px; border-radius: 6px; transition: background .15s;
}
.aicb-close-btn:hover { background: rgba(255,255,255,0.15); }

.aicb-messages {
    flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; background: #f8f9fb;
}
.aicb-messages::-webkit-scrollbar { width: 5px; }
.aicb-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 10px; }

.aicb-msg {
    max-width: 85%; padding: 10px 14px; border-radius: 14px; font-size: 14px;
    line-height: 1.6; word-wrap: break-word; white-space: pre-wrap; animation: aicb-msg-in .25s ease-out;
}

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

.aicb-msg-user {
    background: var(--aicb-primary); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px;
}
.aicb-msg-bot {
    background: #fff; color: #1f2937; align-self: flex-start; border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.aicb-msg-error {
    background: #fef2f2; color: #dc2626; align-self: center; font-size: 13px; border-radius: 8px;
}

.aicb-typing {
    display: flex; align-items: center; gap: 5px; padding: 12px 16px; align-self: flex-start;
    background: #fff; border-radius: 14px; border-bottom-left-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.aicb-typing-dot {
    width: 7px; height: 7px; border-radius: 50%; background: #9ca3af; animation: aicb-bounce 1.2s infinite ease-in-out;
}
.aicb-typing-dot:nth-child(2) { animation-delay: .15s; }
.aicb-typing-dot:nth-child(3) { animation-delay: .3s; }
@keyframes aicb-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

.aicb-input-area {
    display: flex; align-items: flex-end; gap: 8px; padding: 12px 14px;
    border-top: 1px solid #e5e7eb; background: #fff; flex-shrink: 0;
}
.aicb-input {
    flex: 1; border: 1px solid #e5e7eb; border-radius: 12px; padding: 10px 14px;
    font-size: 14px; resize: none; outline: none; max-height: 100px; line-height: 1.5;
    transition: border-color .15s; font-family: inherit;
}
.aicb-input:focus { border-color: var(--aicb-primary); }

.aicb-send-btn {
    width: 40px; height: 40px; border-radius: 50%; background: var(--aicb-primary); color: #fff;
    border: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: opacity .15s;
}
.aicb-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.aicb-send-btn:not(:disabled):hover { opacity: 0.9; }

.aicb-msg-user img { max-width: 100%; border-radius: 8px; margin-top: 6px; }
.aicb-msg-bot img { max-width: 100%; border-radius: 8px; margin-top: 6px; }

.aicb-footer {
    padding: 6px 14px; text-align: center; font-size: 11px; color: #9ca3af;
    background: #fff; border-top: 1px solid #f3f4f6; flex-shrink: 0;
}

@media (max-width: 480px) {
    .aicb-window { width: calc(100vw - 24px); height: calc(100vh - 100px); bottom: 72px; border-radius: 12px; }
    .aicb-chatbot { bottom: 16px; }
    .aicb-position-right { right: 12px; }
    .aicb-position-left { left: 12px; }
    .aicb-toggle { width: 54px; height: 54px; }
}
