html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-width: 320px;
}

body.qa-chat-app {
    min-height: 100svh;
    background: #f3f6fb;
    color: #1f2937;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body.qa-chat-app.admin-bar {
    min-height: calc(100vh - 32px);
}

.qa-chat__tel-template {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
	display:none;
}

.qa-chat-page {
    width: 100%;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.qa-chat-page__inner {
    width: 100%;
    max-width: min(430px, 100vw);
    min-width: 0;
    margin: 0 auto;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    box-sizing: border-box;
}

.qa-chat-page__header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
    color: #ffffff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.qa-chat-page__header img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
}

.qa-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.qa-chat__window {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #f5f5f5;
}

.qa-chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px calc(20px + env(safe-area-inset-bottom));
    box-sizing: border-box;
}

.qa-chat__message {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    margin-bottom: 12px;
    min-width: 0;
}

.qa-chat__message--user {
    justify-content: flex-end;
}

.qa-chat__avatar {
    flex: 0 0 clamp(36px, 10.5vw, 44px);
    width: clamp(36px, 10.5vw, 44px);
    height: clamp(36px, 10.5vw, 44px);
    border-radius: 9999px;
    overflow: hidden;
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.qa-chat__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* 画像の比率を保って収める */
}

.qa-chat__bubble {
    max-width: calc(100% - clamp(36px, 10.5vw, 44px) - 7px);
    min-width: 0;
    margin-right: 0;
    padding: 10px 12px;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
    box-sizing: border-box;
    overflow-wrap: anywhere;
    word-break: normal;
}

.qa-chat__message--bot .qa-chat__bubble {
    border-top-left-radius: 6px;
}

.qa-chat__message--user .qa-chat__bubble {
    max-width: 84%;
    min-width: auto;
    margin-right:0;
    margin-left:auto;
    border-top-right-radius: 6px;
    background: #015cb1;
    color: #ffffff;
}

.qa-chat__bubble p {
    margin: 0;
    color: #015cb1;
    font-weight:700;
    font-size: clamp(15px, 4.2vw, 17px);
    line-height: 1.45;
}

.qa-chat__bubble p + p {
    margin-top: 8px;
}

.qa-chat__message--user .qa-chat__bubble p{
    color:white;
}

.qa-chat__choices {
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;

}

#qaChatCategoryChoices {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.qa-chat__choices--groups {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.qa-chat__choice {
    appearance: none;
    width: 100%;
    min-height: 44px;
    box-sizing: border-box;
	background: #015cb1;
    color: #fff;
    border: 2px solid transparent;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: clamp(14px, 4vw, 16px);
    line-height: 1.45;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s ease;
    text-align:left;
    overflow-wrap: anywhere;
}

.qa-chat__choice:hover,
.qa-chat__choice:focus {
    background: #82adf8;
    border-color: #82adf8;
    outline: none;
}

.qa-chat__footer {
    position: sticky;
    bottom: 0;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
}

@media (min-width: 768px) {
    body.qa-chat-app {
        padding: 24px;
        box-sizing: border-box;
    }

    .qa-chat-page {
        min-height: calc(100vh - 48px);
        min-height: calc(100svh - 48px);
    }

    .qa-chat-page__inner {
        min-height: calc(100vh - 48px);
        min-height: calc(100svh - 48px);
        border-radius: 20px;
        overflow: hidden;
        box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    }

    .qa-chat__messages {
        padding: 20px 18px 24px;
    }

    .qa-chat__bubble {
        max-width: 84%;
        padding: 12px 14px;
    }

    .qa-chat__message--bot .qa-chat__bubble {
        max-width: 82%;
    }

    .qa-chat__message--user .qa-chat__bubble {
        max-width: 82%;
    }
}
/* AI typing 表示 */
.qa-chat__typing {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 20px;
}

.qa-chat__typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 9999px;
    background: #9ca3af;
    opacity: 0.35;
    animation: qaChatTypingBlink 1.2s infinite ease-in-out;
}

.qa-chat__typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.qa-chat__typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes qaChatTypingBlink {
    0%, 80%, 100% {
        opacity: 0.35;
        transform: translateY(0);
    }
    40% {
        opacity: 1;
        transform: translateY(-2px);
    }
}

.qa-chat__choices--image-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.qa-chat__image-action {
    display: block;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    text-decoration: none;
}

.qa-chat__image-action img {
    display: block;
    width: 100%;
    height: auto;
}

.qa-chat__image-action[disabled] {
    opacity: 0.7;
    pointer-events: none;
}
