:root {
    --chat-bg: #fff;
    --chat-header-bg: rgb(14, 180, 155);
    --chat-header-text: #fff;
    --chat-bot-bg: rgb(245, 246, 248);
    --chat-bot-font: #000000;
    --chat-user-bg: rgb(80,80,80);
    --chat-user-font: #fff;
    --chat-inputArea-bg: #fff;
    --chat-input-bg: #f0f0f0;
    --chat-input-font: #000000;
    --chat-form-bg: rgb(14, 180, 155);
    --chat-form-font: #fff;
}
.chatBtn {
    position: fixed;
    bottom: 4%;
    right: 5%;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    display: inline-block;
    z-index: 1;
}

.chatBtn img {
    display: block;
    width: 10vw;
    max-width: 100px;
    min-width: 80px;
    height: auto;
}

.chatBox {
    position: fixed;
    bottom: 15%;
    right: 5%;
    /* width: 40rem; */
    max-width: 50rem;
    height: 73vh;
    background: var(--chat-bg);
    border: 1px solid #ccc;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    transform-origin: bottom right;
    transform: scale(0);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    z-index: 1;
    overflow: hidden;
    touch-action: none;
    overscroll-behavior: contain;
}

.chatBox.show {
    transform: scale(1);
    opacity: 1;
}


.chatHeader {
    background: var(--chat-header-bg);
    color: var(--chat-header-text);
    padding: 8px;
    text-align: center;
    position: relative;
    flex: 0 0 10%;
    display: flex;
    align-items: center;
    border-radius: 8px 8px 0px 0px;
    touch-action: none;
}

.subTitle {
    font-size: 1rem;
    margin-left: 3rem;
}

.closeBtn {
    margin-left: 15rem;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    display: inline-block;
}
.closeBtn img {
    width: 2.5rem;
    height: auto;
}


.chatArea {
    flex: 1;
    padding: 14px;
    overflow-y: auto;
    background-color: var(--chat-bg);
    -webkit-overflow-scrolling: touch;
}
html.lenis-scrolling .chatArea {
  overflow-y: auto !important;  /* Lenis の overflow: hidden を無視 */
  -webkit-overflow-scrolling: touch; /* iOS の慣性スクロール対応 */
}

.preset {
    white-space: pre-line;
    display: inline-block;
    padding: 8px 12px;
    border-radius: 10px;
    max-width: 95%;
    word-break: break-word;
    margin-bottom: 0.5rem;
    background: var(--chat-bot-bg);
    font-size: 16px;
    color: var(--chat-bot-font);
}

.button {
    cursor: pointer;
    justify-items: center;
    border: 1px solid #ccc;
}

.form{
    white-space: pre-line;
    display: inline-block;
    padding: 8px 12px;
    border-radius: 10px;
    max-width: 95%;
    word-break: break-word;
    margin-bottom: 0.5rem;
    background: var(--chat-form-bg);
    font-size: 16px;
    color: var(--chat-form-font);
    cursor: pointer;
    justify-items: center;
}

.userChat {
    white-space: pre-line;
    display: inline-block;
    padding: 15px;
    border-radius: 10px;
    word-break: break-word;
    font-size: 16px;
    margin-bottom: 0.5rem;
    background: var(--chat-user-bg);
    margin-left: 46px;
}
.userChat p {
    color: var(--chat-user-font);
    text-align: left; 
}

.answer {
    white-space: pre-line;
    display: inline-block;
    padding: 15px;
    border-radius: 10px;
    word-break: break-word;
    font-size: 16px;
    margin-bottom: 0.5rem;
    background: var(--chat-bot-bg);
    color: var(--chat-bot-font);
}
.answer p {
    color: var(--chat-bot-font);
}
.fade-char {
    opacity: 0;
    display: inline-block;
    transform: translateY(2px);
    animation-name: fadeIn;
    animation-fill-mode: forwards;
    animation-timing-function: ease-out;
    animation-duration: 1s; /* フェード時間は短め */
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(2px); }
    to { opacity: 1; transform: translateY(0); }
}


.formArea {
    display: flex;
    justify-content: center; /* 横中央 */
    align-items: center;     /* 縦中央 */
    flex: 0 0 15%;
    border-top: 1px solid #ccc;
    touch-action: none;
    background: var(--chat-inputArea-bg);
}

.inputWrapper {
    position: relative;
    display: flex;
    align-items: flex-end;
    width: 80%;
    border-radius: 20px;
    padding: 5px 10px;
    margin: 0 auto;
    background: var(--chat-input-bg);
}

.chatInput {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    padding: 8px;
    resize: none;
    font-size: 17px;
    resize: none;
    line-height: 1.5;
    overflow-y: hidden;
    /*スクロールバー非表示*/max-height: 200px;
    transition: height 0.1s ease;
    padding-right: 30px;
    color: var(--chat-input-font);
}

.sendBtn {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    display: inline-block;
    position: absolute;
    right: 4%;
    bottom: 15px;
}

/* .sendBtn:hover {
    background: #45a049;
} */

.dots-loader {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
}

  /* ドット */
.dots-loader .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: currentColor; /* 親の color を引き継ぐ */
    opacity: 0.25;
    transform: translateY(0);
    animation: dots-bounce 1s infinite ease-in-out;
}

/* 各ドットに遅延をつける */
.dots-loader .dot:nth-child(1) { animation-delay: 0s; }
.dots-loader .dot:nth-child(2) { animation-delay: 0.12s; }
.dots-loader .dot:nth-child(3) { animation-delay: 0.24s; }

.down_B {
    position: fixed;
    width: 40px;
    height: 40px;
    top: 75%;
    right: 5%;
    border-radius: 50%;
    background: rgb(255, 255, 255);
    border: 2px solid #ccc;
    cursor: pointer;
    opacity: 1;
    transition: opacity 0.5s ease;
}
.down_B.fade-out {
    opacity: 0;
    pointer-events: none;
}
.down_B p{
    text-align: center;
    font-size: 20px;
}
/* .down_B img {
    width: 70px;
    position: fixed;
    top: 73%;
    right: 2%;
} */

@keyframes dots-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.25; }
    40% { transform: translateY(-7px); opacity: 1; }
}
/* @keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(2px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    } 
} */

@media screen and (max-width: 767px) {
    .chatBox {
        bottom: 0;
        right: 0;
        z-index: 9999;
        width: 100%;
        height: 100% !important;
        max-width: none;
        transform-origin: bottom center;
        /*←基準を下に*/transform: translateY(100%);
        /*←最初は画面外*/opacity: 1;
        /*透明にはしない*/transition: transform 0.3s ease;
        border-radius:0;
    }
    .chatHeader {
        border-radius:0;
    }
    .chatBox.show {
        transform: translateY(0); /* 下からスライドイン */
    }
    .subTitle {
        margin-left: 2rem;
    }
    .closeBtn {
        margin-left: 9rem;
    }
    .sendBtn {
        position:absolute;
        right: 3%;
        bottom: 10px;
    }
    .chatInput {
        width: 100%;
    }
}

@media screen and (max-height: 873px) {
    .chatBox.show {
        height: 70vh;
    }
}
@media screen and (max-height: 700px) {
    .chatBox.show {
        height: 68vh;
    }
}
@media screen and (max-height: 620px) {
    .chatBox.show {
        height: 62vh;
        /* bottom: 23%; */
    }
    .sendBtn {
        left: 90%;
    }
}
@media screen and (max-height: 430px) {
    .chatBox.show {
        height: 58vh;
    }
}
