/* 右下の「AIで質問」ボタンとチャット画面（includes/ai_widget.php から読み込む）。他のページのCSSと混ざらないよう、すべて cai- で始める */
:root { --cai-grad: linear-gradient(135deg, #5fe3ff 0%, #8fb0ff 38%, #c79bff 68%, #ff8fcf 100%); }

#cai-fab {
    position: fixed; right: 20px; bottom: 20px; z-index: 1100;
    width: 68px; height: 68px; border: 0; border-radius: 50%; padding: 0; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: #fff; font-family: inherit; font-weight: 700;
    background: var(--cai-grad); background-size: 220% 220%;
    box-shadow: 0 8px 26px rgba(120, 150, 255, .5), 0 2px 8px rgba(255, 143, 207, .35);
    animation: cai-grad 7s ease-in-out infinite, cai-ring 3.2s ease-out infinite;
    transition: transform .2s ease;
}
#cai-fab:hover { transform: scale(1.07); }
#cai-fab:focus-visible { outline: 3px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 5px #8fb0ff; }
#cai-fab svg { width: 26px; height: 26px; filter: drop-shadow(0 1px 2px rgba(60, 60, 140, .35)); }
#cai-fab span { font-size: 10.5px; letter-spacing: .04em; line-height: 1; text-shadow: 0 1px 3px rgba(60, 60, 140, .45); }
#cai-fab.cai-open { display: none; }
@keyframes cai-grad { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
@keyframes cai-ring { 0% { box-shadow: 0 8px 26px rgba(120, 150, 255, .5), 0 0 0 0 rgba(143, 176, 255, .55); } 70%, 100% { box-shadow: 0 8px 26px rgba(120, 150, 255, .5), 0 0 0 18px rgba(143, 176, 255, 0); } }
/* スマホで下に固定バー（電話・予約）があるページでは、その上に置く */
#cai-fab.cai-lift { bottom: calc(92px + env(safe-area-inset-bottom)); }
@media (prefers-reduced-motion: reduce) { #cai-fab { animation: none; } }

#cai-panel {
    position: fixed; right: 20px; bottom: 20px; z-index: 1200;
    width: 384px; height: min(620px, calc(100vh - 40px)); display: none; flex-direction: column;
    background: #fff; border-radius: 20px; overflow: hidden;
    box-shadow: 0 18px 60px rgba(60, 70, 140, .35), 0 2px 10px rgba(0, 0, 0, .12);
    font-family: inherit; color: #2a2a3a;
}
#cai-panel.cai-show { display: flex; animation: cai-pop .22s ease-out; }
@keyframes cai-pop { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }

.cai-head { background: var(--cai-grad); color: #fff; padding: 14px 16px; display: flex; align-items: center; gap: 10px; }
.cai-head svg { width: 26px; height: 26px; flex: none; }
.cai-head-t { flex: 1; line-height: 1.3; }
.cai-head-t b { display: block; font-size: 15px; letter-spacing: .02em; }
.cai-head-t small { font-size: 11px; opacity: .92; }
.cai-reset { border: 0; background: rgba(255, 255, 255, .25); color: #fff; width: 30px; height: 30px; border-radius: 50%; font-size: 17px; line-height: 1; cursor: pointer; }
.cai-reset:hover { background: rgba(255, 255, 255, .4); }
.cai-close { border: 0; background: rgba(255, 255, 255, .25); color: #fff; width: 30px; height: 30px; border-radius: 50%; font-size: 18px; line-height: 1; cursor: pointer; }
.cai-close:hover { background: rgba(255, 255, 255, .4); }

.cai-notice { background: #f3f6ff; color: #55608a; font-size: 11px; line-height: 1.55; padding: 8px 14px; border-bottom: 1px solid #e4e9fb; }
.cai-notice a { color: #5a6fe0; }

.cai-log { flex: 1; overflow-y: auto; padding: 14px; background: #fafbff; -webkit-overflow-scrolling: touch; }
.cai-msg { display: flex; margin-bottom: 10px; }
.cai-msg.cai-u { justify-content: flex-end; }
.cai-bub { max-width: 88%; padding: 10px 13px; border-radius: 16px; font-size: 14px; line-height: 1.7; word-break: break-word; background: #fff; border: 1px solid #e6e9f5; border-top-left-radius: 4px; }
.cai-msg.cai-u .cai-bub { background: var(--cai-grad); color: #fff; border: 0; border-top-left-radius: 16px; border-top-right-radius: 4px; }
.cai-bub a { color: #4f63d8; text-decoration: underline; }
.cai-note { font-size: 11.5px; color: #7a7f99; margin-top: 6px; line-height: 1.55; }

.cai-chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 4px 0 10px; }
.cai-chip { border: 1px solid #c9d3ff; background: #fff; color: #4b5bc4; border-radius: 18px; padding: 7px 12px; font-size: 12.5px; cursor: pointer; font-family: inherit; }
.cai-chip:hover { background: #eef1ff; }

.cai-card { background: #fff; border: 1px solid #dfe5fb; border-radius: 12px; padding: 8px 11px; margin: 5px 0 6px; max-width: 94%; font-size: 12.5px; line-height: 1.55; }
.cai-card-g, .cai-card-c { color: #444a66; margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cai-card-g b, .cai-card-c b { display: inline-block; margin-right: 6px; padding: 0 6px; border-radius: 4px; background: #eef1ff; color: #3d4aa8; font-size: 11px; font-weight: 700; }
.cai-card details { margin-top: 4px; font-size: 12px; color: #6b6f88; }
.cai-card summary { cursor: pointer; color: #5a6fe0; }
.cai-ng { margin-top: 3px; color: #c0392b; }
.cai-more { margin: 2px 0 8px; }
.cai-card-t { font-weight: 700; color: #3d4aa8; font-size: 14px; }
.cai-card-t small { font-weight: 400; color: #7a7f99; margin-left: 6px; }
.cai-card-s { color: #555a75; }
.cai-card a { display: inline-block; margin-top: 6px; padding: 6px 12px; background: #3d4aa8; color: #fff !important; text-decoration: none; border-radius: 8px; font-size: 12.5px; }
.cai-card a:hover { background: #2f3b8f; }

.cai-typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.cai-typing i { width: 7px; height: 7px; border-radius: 50%; background: #aab6ee; animation: cai-dot 1.1s infinite ease-in-out; }
.cai-typing i:nth-child(2) { animation-delay: .15s; } .cai-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes cai-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.cai-form { display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid #e8ebf7; background: #fff; }
.cai-form input { flex: 1; min-width: 0; border: 1px solid #d5dcf5; border-radius: 22px; padding: 10px 14px; font-size: 16px; font-family: inherit; outline: none; }
.cai-form input:focus { border-color: #8fb0ff; box-shadow: 0 0 0 3px rgba(143, 176, 255, .25); }
.cai-form button { border: 0; border-radius: 22px; padding: 0 16px; color: #fff; font-weight: 700; background: var(--cai-grad); cursor: pointer; font-family: inherit; }
.cai-form button:disabled { opacity: .5; cursor: default; }
.cai-foot { text-align: center; font-size: 10.5px; color: #9aa0bb; padding: 0 12px 8px; background: #fff; }

@media (max-width: 600px) {
    #cai-panel { inset: 0; width: 100%; height: 100%; border-radius: 0; }
    #cai-fab { right: 12px; bottom: calc(18px + env(safe-area-inset-bottom)); width: 58px; height: 58px; }
    #cai-fab svg { width: 23px; height: 23px; }
    #cai-fab span { font-size: 9.5px; }
    #cai-fab.cai-lift { bottom: calc(92px + env(safe-area-inset-bottom)); }   /* 固定バーの高さ(約72px)＋余白 */
}
