@charset "UTF-8";

/* HomeBot のサイト埋め込み: ランチャー（入口）。mu-plugins/kicocochi-homebot.php が読み込む。
   チャット窓の中身は共通ウィジェット（Shadow DOM）側＝ここでは触らない。
   配置は js/homebot-guide.js が計測する値に合わせる:
     --kchb-cta-bottom     … 1240px 以下で下部CTAになる .headerContent-vertical の実測の高さ（非表示中は 0）
     --kchb-launcher-right … PC で右端の縦CTA（.headerContent-vertical）と重なるときだけ、その左に逃がす右位置
   チャット窓の位置は JS が共通ウィジェットの HomeBot.configure の layout で渡す（未対応の版では --homebot-offset-*）。
   ランチャーは JS が theme-v1 の外部入口ハンドシェイクの受理を確認してから hidden を外す（受理されなければ標準のランチャーのまま）。
   既存の固定要素（.headerContent・.headerContent-vertical・.headerContent-vertical_sns）は隠さず、見た目も変えない。 */

/* ===== ランチャー ===== */
/* 横長のピル（ロゴの白丸 → 状態の点と補足・ラベル → 吹き出しの丸）。サイトのセージ #889687 の単色に白文字・白い状態の点。文字の影は付けない */
.kchb-launcher {
    --kchb-homebot-assets-ready: 1; /* このCSSが読めた印。js/homebot-guide.js が確認してから入口を引き継ぐ（404 なら標準のランチャーのまま） */
    position: fixed;
    right: var(--kchb-launcher-right, 58px); /* 開いたチャット窓の右端と同じ */
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    z-index: 950; /* .headerContent-vertical（900）・.headerContent（100）より上、ローディング（9999）・.modal（10000）より下 */
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 60px;
    max-width: calc(100vw - 32px);
    margin: 0;
    padding: 8px 10px 8px 8px;
    border: 0;
    border-radius: 40px;
    background: #889687;
    color: #fff;
    font-family: inherit;
    line-height: 1.35;
    text-align: left;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .22);
    cursor: pointer;
    box-sizing: border-box;
}
.kchb-launcher[hidden] { display: none; }
body.open .kchb-launcher { display: none; } /* ハンバーガーメニュー（body.open）を開いている間は隠す */
.kchb-launcher:hover {
    background: #889687; /* 色は変えず、影だけを強める */
    box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
}
.kchb-launcher:focus { outline: none; }
.kchb-launcher:focus-visible { outline: 3px solid #111111; outline-offset: 3px; }

.kchb-launcher__icon {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #fff;
    overflow: hidden;
}
/* ロゴ（img/logo/logo.svg 184×30 の左端＝家のマーク）。高さに合わせて縮め、左端の正方形だけを見せる。
   マークが viewBox の左端から少し右にあるため、2px 右へずらして円の中央に置く */
.kchb-launcher__mark {
    display: block;
    width: 26px;
    max-width: none;
    height: 26px;
    object-fit: cover;
    object-position: 2px center;
}
.kchb-launcher__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kchb-launcher__sub {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .05em;
    color: #fff;
    white-space: nowrap;
}
.kchb-launcher__dot {
    flex-shrink: 0;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #fff;
}
.kchb-launcher__label {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: .03em;
}
/* 狭い画面では「、」の後で折り返す（途中で切らない） */
.kchb-launcher__phrase { display: inline-block; white-space: nowrap; }

/* 吹き出しの丸（飾り。ボタンは1つのまま）。濃いグレー #414141 の小さな丸に白い吹き出し */
.kchb-launcher__go {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    margin-left: 2px;
    border-radius: 50%;
    background: #414141;
}
.kchb-launcher__bubble {
    position: relative;
    display: block;
    width: 19px;
    height: 15px;
    margin-bottom: 3px; /* しっぽの分だけ上げて円の中央に見せる */
    border-radius: 7px;
    background: #fff;
}
/* 吹き出しの中の点 3 つ（地の濃いグレーで抜く） */
.kchb-launcher__bubble::before {
    content: "";
    position: absolute;
    top: 6px;
    left: 3px;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: #414141;
    box-shadow: 5px 0 0 #414141, 10px 0 0 #414141;
}
/* しっぽ（左下） */
.kchb-launcher__bubble::after {
    content: "";
    position: absolute;
    bottom: -4px;
    left: 3px;
    border-style: solid;
    border-width: 5px 5px 0 0;
    border-color: #fff transparent transparent transparent;
}

@media screen and (max-width: 1240px) {
    /* .headerContent-vertical が画面下の横長CTAになる幅。実測の高さ（非表示中は 0）の上に置く */
    .kchb-launcher {
        right: 58px;
        bottom: calc(var(--kchb-cta-bottom, 0px) + 12px + env(safe-area-inset-bottom, 0px));
    }
}
@media screen and (max-width: 767px) {
    /* スマホは左下 */
    .kchb-launcher {
        right: auto;
        left: 12px;
        bottom: calc(var(--kchb-cta-bottom, 0px) + 10px + env(safe-area-inset-bottom, 0px));
        gap: 10px;
        min-height: 54px;
        max-width: calc(100vw - 24px);
        padding: 6px 8px 6px 6px;
    }
    .kchb-launcher__icon { width: 40px; height: 40px; }
    .kchb-launcher__mark { width: 24px; height: 24px; }
    .kchb-launcher__sub { font-size: 10px; }
    .kchb-launcher__label { font-size: 14px; }
    .kchb-launcher__go { width: 32px; height: 32px; }
}
@media screen and (max-width: 400px) {
    .kchb-launcher { gap: 8px; }
    .kchb-launcher__label { font-size: 13px; }
}
@media screen and (max-width: 359px) {
    .kchb-launcher__icon { width: 36px; height: 36px; }
    .kchb-launcher__mark { width: 22px; height: 22px; }
    .kchb-launcher__sub { white-space: normal; }
    .kchb-launcher__go { width: 28px; height: 28px; margin-left: 0; }
}

/* ===== チャット窓の見出し（共通ウィジェットの公開UI契約 theme-v1 のトークンと公開 part） =====
   ウィジェット本体が公開する --homebot-ui-* と ::part(close-button) だけを使う。Shadow DOM の内部・内部クラスには触らない。
   theme-v1 に未対応の版では無視され、管理画面のテーマカラーの見出しのまま。ボットの設定は変更しない */
#homebot-widget {
    --homebot-ui-header-background: #889687; /* 見出しの地色（ランチャーと同じセージ・単色） */
    --homebot-ui-header-foreground: #ffffff; /* 見出しのタイトル・閉じる× */
    --homebot-ui-header-secondary: #ffffff; /* 補足の文・AI表示の文字 */
    --homebot-ui-ai-border: #ffffff; /* AI表示の枠 */
    --homebot-ui-avatar-background: #ffffff; /* ロゴの台座（白） */
    --homebot-ui-avatar-foreground: #111111; /* 白い台座の上の標準の家のアイコン */
}
/* 閉じる×（公開 part）: 標準のホバーの淡い地色では白い×が、標準のフォーカス枠（テーマカラー）ではセージの見出しが同化するため、
   濃いセージの地色と白い枠にする。×の色はどの状態でも白 */
#homebot-widget[data-homebot-ui-active="theme-v1"]::part(close-button):hover { background: #5f6d5e; color: #ffffff; }
#homebot-widget[data-homebot-ui-active="theme-v1"]::part(close-button):active { background: #4d5a4c; color: #ffffff; }
#homebot-widget[data-homebot-ui-active="theme-v1"]::part(close-button):focus-visible { outline-color: #ffffff; }
