#andbot-chat-root {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
}

.andbot-chat-root--inline {
    position: static;
    bottom: auto;
    right: auto;
    left: auto;
    width: 100%;
    max-width: 720px;
    margin: 24px auto;
}

.andbot-chat {
    position: relative;
    width: 320px;
    max-width: calc(100vw - 32px);
    color: #1e1e1e;
    --andbot-accent-start: #4c6ef5;
    --andbot-accent-end: #7b5bff;
    --andbot-accent-solid: #4c6ef5;
}

.andbot-chat__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, var(--andbot-accent-start), var(--andbot-accent-end));
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(76, 110, 245, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    width: 100%;
}

.andbot-chat__toggle:hover,
.andbot-chat__toggle:focus {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(76, 110, 245, 0.45);
}

.andbot-chat-root--inline .andbot-chat {
    width: 100%;
    max-width: none;
}

.andbot-chat-root--inline .andbot-chat__toggle,
.andbot-chat-root--inline .andbot-chat__close {
    display: none;
}

.andbot-chat__panel {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 100%;
    max-height: 480px;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.andbot-chat-root--inline .andbot-chat__panel {
    position: static;
    opacity: 1;
    pointer-events: auto;
    transform: none;
    max-height: 70vh;
}

.andbot-chat[data-open="true"] .andbot-chat__panel {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.andbot-chat__header {
    padding: 18px 20px;
    border-bottom: 1px solid #e8e8e8;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.andbot-chat__title {
    font-size: 1.05rem;
    font-weight: 800;
    color: #1e1e1e;
}

.andbot-chat__close {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1.1rem;
    color: #999;
}

.andbot-chat__messages {
    flex: 1;
    padding: 16px 16px 12px;
    overflow-y: auto;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.andbot-chat__message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: .88rem;
    line-height: 1.65;
    margin-bottom: 0;
}

.andbot-chat__message--user {
    background: #1e1e1e;
    color: #fff;
    align-self: flex-end;
}

.andbot-chat__message--bot {
    background: #f0f0f0;
    color: #1e1e1e;
    align-self: flex-start;
}

.andbot-chat__message--error {
    background: #f0f0f0;
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #b91c1c;
    align-self: flex-start;
}

.andbot-chat__message--no-knowledge {
    background: #f0f0f0;
    color: #1e1e1e;
    align-self: flex-start;
}

/* Bot アイコン付き行（アイコンが設定されているときのみ追加される） */
.andbot-chat__row {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 8px;
    max-width: 100%;
}

.andbot-chat__row--bot {
    justify-content: flex-start;
    align-self: flex-start;
}

.andbot-chat__row--with-avatar .andbot-chat__message {
    /* row 内に置かれた場合、align-self は行に対しては無効。max-width を行幅に合わせて再指定 */
    max-width: calc(100% - 40px);
    align-self: auto;
}

.andbot-chat__avatar {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    background: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
}

.andbot-chat__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.andbot-chat__answer-footer {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    font-size: .8rem;
    line-height: 1.6;
    color: #555;
}

.andbot-chat__answer-footer a {
    color: var(--andbot-accent-solid, #4c6ef5);
    text-decoration: underline;
    word-break: break-all;
}

.andbot-chat__answer-footer a:hover {
    text-decoration: none;
}

.andbot-chat__sources {
    margin-top: 8px;
    padding-left: 0;
    list-style: none;
    font-size: .72rem;
    font-weight: 700;
    color: var(--andbot-accent-solid, #4c6ef5);
}

.andbot-chat__sources-label {
    display: block;
    margin-bottom: 4px;
}

.andbot-chat__sources li {
    margin-bottom: 2px;
    padding-left: 12px;
    position: relative;
}

.andbot-chat__sources li::before {
    content: "-";
    position: absolute;
    left: 0;
}

.andbot-chat__sources a {
    color: var(--andbot-accent-solid, #4c6ef5);
    text-decoration: none;
}

.andbot-chat__sources a:hover {
    text-decoration: underline;
}

.andbot-chat__form {
    border-top: 1px solid #e8e8e8;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.andbot-chat__textarea {
    width: 100%;
    min-height: 52px;
    max-height: 120px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #e8e8e8;
    font-size: 16px;
    font-family: inherit;
    resize: none;
    box-sizing: border-box;
    max-width: 100%;
    outline: none;
    color: #1e1e1e;
}

.andbot-chat__textarea::placeholder {
    color: #999;
}

.andbot-chat__submit {
    align-self: flex-end;
    padding: 9px 24px;
    border-radius: 20px;
    border: none;
    background: var(--andbot-accent-solid);
    color: #fff;
    font-size: .82rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.andbot-chat__submit[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.andbot-chat__status {
    font-size: .72rem;
    color: #999;
    padding: 0 16px;
}

.andbot-chat__status:empty {
    display: none;
}

.andbot-chat__privacy-notice {
    font-size: 0.7rem;
    color: #999;
    text-align: center;
    padding: 0 16px 4px;
    line-height: 1.5;
    white-space: pre-line;
}

.andbot-chat__privacy-notice a {
    color: #999;
    text-decoration: underline;
}

.andbot-chat__privacy-notice a:hover {
    color: #666;
}

.andbot-chat__retry {
    margin-top: 8px;
    padding: 6px 12px;
    border-radius: 20px;
    border: none;
    background: #ef4444;
    color: #fff;
    cursor: pointer;
    font-size: .72rem;
    font-weight: 700;
}

@media (max-width: 768px) {
    #andbot-chat-root {
        right: 16px;
        left: 16px;
        bottom: var(--andbot-mobile-bottom, 16px);
        width: auto;
    }

    .andbot-chat {
        width: 100%;
        max-width: none;
    }

    .andbot-chat__panel {
        position: fixed;
        right: 16px;
        left: 16px;
        bottom: calc(var(--andbot-mobile-bottom, 16px) + 84px);
        width: auto;
        max-width: none;
        max-height: 70vh;
    }

    .andbot-chat-root--inline {
        right: auto;
        left: auto;
        bottom: auto;
        width: 100%;
    }

    .andbot-chat-root--inline .andbot-chat__panel {
        position: static;
        right: auto;
        left: auto;
        bottom: auto;
        width: 100%;
        max-height: 70vh;
    }
}

/* Fullscreen mode styles */
.andbot-chat-root--fullscreen {
    position: relative;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 400px;
    bottom: auto;
    right: auto;
    left: auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
}

.andbot-chat--fullscreen {
    width: 100%;
    height: 100%;
    max-width: none;
}

.andbot-chat--fullscreen .andbot-chat__toggle {
    display: none !important;
}

.andbot-chat--fullscreen .andbot-chat__panel {
    position: relative;
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
    opacity: 1;
    pointer-events: auto;
    transform: none;
    bottom: auto;
    box-shadow: none;
}

.andbot-chat--fullscreen .andbot-chat__close {
    display: none;
}

.andbot-chat--fullscreen .andbot-chat__header {
    border-radius: 0;
}

.andbot-chat--fullscreen .andbot-chat__messages {
    flex: 1;
    min-height: 0;
    max-height: none;
}

.andbot-chat--fullscreen .andbot-chat__form {
    padding: 16px 24px;
}

.andbot-chat--fullscreen .andbot-chat__textarea {
    min-height: 80px;
}

@media (max-width: 768px) {
    .andbot-chat-root--fullscreen {
        height: 100vh;
        height: 100dvh;
        min-height: 300px;
    }

    .andbot-chat--fullscreen .andbot-chat__panel {
        position: relative;
        left: auto;
        right: auto;
        bottom: auto;
    }

    .andbot-chat--fullscreen .andbot-chat__form {
        padding: 12px 16px;
    }

    .andbot-chat--fullscreen .andbot-chat__textarea {
        min-height: 60px;
    }
}
