/* アンカージャンプ時の固定ヘッダー対策 */
#model-name, #WelcomeBack, #BIG-AE, #Height-AE { scroll-margin-top: 100px !important; }

/* ▼ 全体のラッパー（画面左端に固定） ▼ */
#ai-floating-wrap {
    position: fixed; left: 0; 
    z-index: 9990;
    display: flex; align-items: center;
    opacity: 0; visibility: hidden;
    transition: bottom 0.3s ease, opacity 0.3s ease, visibility 0.3s ease;
}
/* スクロールで表示 */
#ai-floating-wrap.show {
    opacity: 1; visibility: visible;
}

/* ▼ 展開時のメインボタン ▼ */
#ai-floating-btn {
    margin-left: 15px; 
    width: 125px; 
    height: 52px; 
    background: #fcfcfc;
    border: 1px solid #d4d4d4;
    border-radius: 8px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.22);
    box-shadow: inset 0 4px 0 #fff, inset 0 -2px 0 #aaa;
    cursor: pointer;
    display: flex; align-items: center; padding: 0 6px 0 8px;
    position: relative;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.3s, box-shadow 0.3s;
}
#ai-floating-btn:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}
#ai-floating-wrap.is-collapsed #ai-floating-btn {
    transform: translateX(-150%);
    opacity: 0; pointer-events: none;
}
#ai-floating-btn:active { transform: scale(0.96); }

/* ▼ アイコンとテキストのレイアウト ▼ */
#ai-btn-content {
    display: flex; align-items: center; width: 100%;
}
.ai-assist-icon { 
    font-size: 22px; line-height: 1; margin-right: 6px; 
}
.ai-btn-text { 
    font-size: 14px; font-weight: bold; letter-spacing: 0px; 
    line-height: 1.3; color: #222222; text-align: left;
}

/* ▼ タイプライターアニメーション用 ▼ */
.ai-tw-char {
    opacity: 0;
}
#ai-floating-wrap.show .ai-tw-char {
    animation: aiTypeChar 0.05s forwards;
}
@keyframes aiTypeChar {
    to { opacity: 1; }
}

/* ▼ 右上の小さな「×」収納ボタン ▼ */
#ai-btn-close {
    position: absolute; top: -8px; right: -8px;
    width: 22px; height: 22px;
    background: #fff; border: 1px solid #ddd; color: #999;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; line-height: 1; font-weight: bold;
    cursor: pointer; box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 10; transition: transform 0.2s, color 0.2s;
}
#ai-btn-close:hover { color: #ff0000; transform: scale(1.1); }

/* ▼ 収納時の引き出しタブ ▼ */
#ai-floating-tab {
    position: absolute; left: 0; top: 50%; 
    width: 22px; height: 54px; 
    background: #ffffff; border: 1px solid #eaeaea; border-left: none;
    border-radius: 0 6px 6px 0; box-shadow: 2px 0 6px rgba(0,0,0,0.1);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: bold; color: #777; cursor: pointer;
    transform: translateY(-50%) translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
#ai-floating-wrap.is-collapsed #ai-floating-tab {
    transform: translateY(-50%) translateX(0);
}

/* ▼ オーバーレイ ▼ */
#ai-modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6); 
    z-index: 9999998; 
    opacity: 0; visibility: hidden; transition: opacity 0.3s;
}
#ai-modal-overlay.active { opacity: 1; visibility: visible; }

/* ▼ ハーフモーダル全体 ▼ */
#ai-half-modal {
    position: fixed; bottom: -100%; left: 0; width: 100%;
    background: #fff; border-radius: 20px 20px 0 0;
    padding: 20px 15px 10vh; box-sizing: border-box;
    z-index: 9999999; 
    transition: bottom 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    max-height: 85vh; overflow-y: auto; scrollbar-width: none;
}
#ai-half-modal::-webkit-scrollbar { display: none; }
#ai-half-modal.active { bottom: 0; }

.ai-modal-close-btn {
    position: sticky; top: 0; float: right; 
    width: 50px; height: 50px; background: #777; color: #fff;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 25px; cursor: pointer; font-weight: bold; line-height: 1; z-index: 10005;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3); margin-top: -10px; margin-right: -5px;
}
.ai-modal-close-btn:active { transform: scale(0.9); }

.ai-modal-inner { max-width: 800px; margin: 0 auto; position: relative; clear: both; }
.ai-modal-title { text-align: center; font-size: 19px; font-weight: bold; margin-top: 75px; margin-bottom: 22px; color: #88A80D; box-shadow: 0px 5px 4px -4px #eee; }
.ai-modal-title2nd { text-align: center; font-size: 18px; font-weight: bold; margin-top: 40px; margin-bottom: 20px; color: #666; box-shadow: 0px 4px 3px -3px #eee; }
.ai-modal-title3rd { text-align: center; font-size: 16px; font-weight: normal; margin-top: 30px; margin-bottom: 15px; color: #444; box-shadow: 0px 6px 4px -4px #eee;}

/* 査定ボタングループ */
.ai-choice-btn {
    display: flex; align-items: center; justify-content: center;
    width: 100%; padding: 18px 13px; margin-bottom: 17px;
    border-radius: 10px; border: 2px solid #ccc;
    background: #fafafa; color: #333; cursor: pointer; transition: all 0.2s; box-sizing: border-box; box-shadow: 0px 5px 4px -4px #eee;
    box-shadow: inset 0 4px 0 #fff, inset 0 -1px 0 #ccc;
}
.ai-choice-btn:hover {
    opacity:0.8;
    background-color:#f8fce8;
}
.ai-primary-btn { border-color: #ccc; background: #fafafa; }
.ai-btn-icon { font-size: 33px; margin-right: 12px; }
.ai-btn-body { text-align: left; font-size: 22px; font-weight: bold; line-height:1.4;}
.ai-btn-body small { display: block; font-size: 11px; color: #666; font-weight: normal; margin-top:2px;}

/* メーカーグリッド */
.ai-maker-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.ai-maker-item, .ai-maker-item:link, .ai-maker-item:visited {
    display: flex; align-items: center; justify-content: center;
    border: 1px solid #ccc; border-radius: 6px; padding: 10px 5px;
    text-decoration: none !important; color: #333 !important; font-weight: bold; font-size: 13px; background: #fff;
    transition: background 0.2s; cursor: pointer; box-sizing: border-box;
}
.ai-maker-item:active { background: #f0f0f0; }
.ai-maker-item img { height: 18px; margin-right: 8px; object-fit: contain; }
.ai-back-link { text-align: center; margin-top: 20px; color: #666; text-decoration: underline; cursor: pointer; font-size:14px; }

#ai-maker-menu {
    min-height: 55vh;
    padding-top: 3vh;
}

/* ▼ チャット風 FAQ アコーディオン ▼ */
.ai-accordion {
    background: transparent; padding: 12px 5px; border-bottom: 1px dashed #eee; margin-bottom: 0;
    cursor: pointer; display: flex; justify-content: space-between; align-items: flex-end;
}
.ai-user-bubble {
    background: #f9f9f9; padding: 10px 15px 10px 12px; border-radius: 15px 15px 0 15px; border: 1px solid #eee;
    display: flex; align-items: center; font-weight: bold; font-size: 15px; color: #333; line-height: 1.4;
}
.ai-user-bubble::before {
    content: 'Q.';
    display: flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; background: #fc8181; color: #fff;
    border-radius: 50%; font-size: 13px; font-weight: bold;
    margin-right: 8px; flex-shrink: 0;
}
.ai-user-bubble:hover {
    opacity:0.7;
}
.ai-accordion span { font-size: 12px; color: #bbb; transition: transform 0.2s; margin-bottom: 5px; margin-left: 10px; min-width:12px; }
.ai-accordion.open span { transform: rotate(180deg); }
.ai-accordion-content { display: none; padding: 15px 0 20px; }

.ai-chat-answer { display: flex; align-items: flex-start; }
.ai-chat-icon { min-width: 50px; }
.ai-chat-bubble {
    background: #fff; border: 1px solid #e0e0e0; border-radius: 0 15px 15px 15px;
    padding: 15px; font-size: 16px; color: #333; line-height: 1.6;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04); width: 100%;
}
.ai-slide-item { border: 1px solid #eee; border-radius:8px; padding: 0.1px; }
.ai-typewriter-text { min-height: 20px; }
@keyframes aiSmashIn { 0% { transform: scale(2.5) rotate(5deg); opacity: 0; } 50% { opacity: 1; } 100% { transform: scale(1) rotate(0deg); opacity: 1; } }
.ai-smash-img { width: 100%; display: block; opacity: 0; transform-origin: center center; }
.ai-smash-img.active { animation: 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0s 1 normal forwards running aiSmashIn; }
.ai-q4-image-grid { display: flex; flex-direction: column; gap: 15px; margin-top: 15px; }
.ai-q4-img-wrap { overflow: hidden; border-radius: 8px; border: 3px solid #ffcc00; box-shadow: 0 5px 15px rgba(0,0,0,0.2); background: #000; display: block; text-decoration: none; }
.ai-q4-img-wrap:nth-child(2) .ai-smash-img.active { animation-delay: 0.15s; }
.ai-chat-rich-content { display: none; opacity: 0; transition: opacity 0.5s ease; margin-top: 15px; }

/* 電話番号リッチUI */
.ai-tel-link {
    display: flex; align-items: center; justify-content: center;
    background: #fefefe; border: 1px solid #fafafa; border-radius: 12px;
    padding: 12px 15px; margin-top: 12px; text-decoration: none;
    color: #333; box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    transition: all 0.2s ease; width: 100%; box-sizing: border-box;
}
.ai-tel-link:active { background: #fafafa; transform: scale(0.98); }
.ai-tel-icon { font-size: 20px; margin-right: 12px; }
.ai-tel-text { display: flex; flex-direction: column; align-items: flex-start; }
.ai-tel-label { font-size: 11px; color: #6b7280; margin-bottom: 2px; }
.ai-tel-number { font-size: 18px; font-weight: bold; font-family: sans-serif; letter-spacing: 0.5px; color:#88A80D; }
.ai-tel-number small { font-size: 11px; font-weight: normal; color: #6b7280; margin-left: 4px; }

/* フロー(Step)画像用 */
.ai-slide-item { opacity: 0; transform: translateY(20px); }
.ai-slide-item.active { animation: aiSlideUp 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
@keyframes aiSlideUp { to { opacity: 1; transform: translateY(0); } }
.ai-slide-item:nth-child(1).active { animation-delay: 0.05s; }
.ai-slide-item:nth-child(2).active { animation-delay: 0.15s; }
.ai-slide-item:nth-child(3).active { animation-delay: 0.25s; }
.ai-slide-item:nth-child(4).active { animation-delay: 0.35s; }
.ai-slide-item img { width: 100%; border-radius: 6px; }
.ai-slide-item p { margin-top: 8px; font-size: 11px; color: #444; line-height: 1.4; text-align: left;}

/* ▼ PC/SP 分岐スタイル ▼ */
@media (min-width: 768px) {
    .ai-satei-btn-group { display: flex; gap: 15px; }
    .ai-satei-btn-group .ai-choice-btn { flex: 1; margin-bottom: 0; }
    .ai-maker-grid { grid-template-columns: repeat(5, 1fr); }
    .ai-slide-wrapper { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
    .ai-q4-image-grid { flex-direction: row; } 
    .ai-q4-img-wrap { flex: 1; }
}
@media (max-width: 767px) {
    .ai-slide-wrapper {
        display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 10px;
        scrollbar-width: none; padding-bottom: 10px;
    }
    .ai-slide-wrapper::-webkit-scrollbar { display: none; }
    .ai-slide-item { flex: 0 0 75%; scroll-snap-align: center; }
}

.ai-book-btn {
    display: inline-block; background: #fa2020; color: #fff; text-decoration: none;
    padding: 12px 20px; border-radius: 30px; font-weight: bold; font-size: 16px;
    box-shadow: 0 3px 10px rgba(255,0,0,0.3); border:none; cursor:pointer; width:100%; max-width:300px;
}