/* ===== Grantbot scoped styles (no global pollution) ===== */
:root {}

/* ===== 共通定義（全デバイス） ===== */
.grantbot-btn {
    position: fixed;
    right: 30px;
    bottom: 100px;
    z-index: 2147483000;

    padding: 0;
    width: 56px;
    height: 56px;
    border: 0;
    background: transparent;
    cursor: pointer;
}

/* ===== PC（1101px〜） ===== */
@media (min-width:1101px) {
    .grantbot-btn {
        position: fixed;
        right: 30px;
        bottom: 100px;
        z-index: 2147483000;

        padding: 0;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        border: 0;
        background: transparent;
        cursor: pointer;
        box-shadow: 0 6px 16px rgba(0, 0, 0, .15);

        display: flex;
        align-items: center;
        justify-content: center;
    }

    .grantbot-btn img {
        width: 100%;
        height: 100%;
        border-radius: 50%;
        display: block;
    }
}


/* ホバー時（少し薄くするだけ） */
.grantbot-btn:hover {
    opacity: .9;
}


/* パネル（ウィンドウ本体） */
.grantbot-panel {
    position: fixed;
    right: 30px;
    bottom: 170px;
    /* ボタンのさらに上 */
    width: min(420px, calc(100vw - 32px));
    height: 60vh;
    display: none;
    /* JSで切替 */
    flex-direction: column;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
    overflow: hidden;
    z-index: 2147483000;
    border: 1px solid #e5e7eb;
    font: 14px/1.6 system-ui, -apple-system, "Segoe UI", Roboto,
        "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", "Meiryo",
        sans-serif;
    color: #111827;
}

/* ヘッダ */
.grantbot-panel .grantbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: #111827;
    color: #fff;
}

/* アイコン + タイトルのラッパー */
.grantbot-panel .grantbot-header-main {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* アイコン画像 */
.grantbot-panel .grantbot-icon {
    width: 24px;
    height: 24px;
    border-radius: 9999px;
    object-fit: cover;
    background: #fff;
    flex-shrink: 0;
}

.grantbot-panel .grantbot-title {
    font-weight: 600;
    font-size: 14px;
}

.grantbot-panel .grantbot-close {
    appearance: none;
    background: transparent;
    border: 0;
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

/* 本文エリア */
.grantbot-panel .grantbot-body {
    flex: 1 1 auto;
    overflow: auto;
    padding: 12px;
    background: #f9fafb;
}

/* 気泡 */
.grantbot-panel .grantbot-row {
    margin: 8px 0;
    display: flex;
}

.grantbot-panel .grantbot-row.user {
    justify-content: flex-end;
}

.grantbot-panel .grantbot-bubble {
    max-width: 85%;
    padding: 10px 12px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid #e5e7eb;
    word-break: break-word;
    font-size: 13px;
}

.grantbot-panel .grantbot-row.user .grantbot-bubble {
    background: #e0ecff;
    border-color: #c7ddff;
}

/* 入力エリア */
.grantbot-panel .grantbot-input {
    display: flex;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
}

.grantbot-panel #grantbot-input {
    flex: 1 1 auto;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #d1d5db;
    font: inherit;
}

.grantbot-panel .grantbot-send {
    appearance: none;
    border: 0;
    border-radius: 10px;
    padding: 10px 14px;
    background: #2563eb;
    color: #fff;
    cursor: pointer;
}

.grantbot-panel .grantbot-send:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* フッタ文言 */
.grantbot-panel .grantbot-footnote {
    padding: 6px 10px 10px;
    font-size: 11px;
    color: #6b7280;
    word-break: break-word;
}

.grantbot-panel .grantbot-footnote a {
    color: #2563eb;
    text-decoration: underline;
}

/* CTA / 参照リンク */
.grantbot-panel .grantbot-cta {
    margin-top: 8px;
}

.grantbot-panel .grantbot-cta .grantbot-open-lead {
    appearance: none;
    border: 1px solid #d1d5db;
    background: #fff;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
}

.grantbot-panel .grantbot-cites {
    margin-top: 10px;
    font-size: 12px;
}

.grantbot-panel .grantbot-cites ul {
    margin: 6px 0 0;
    padding-left: 18px;
}

.grantbot-panel .grantbot-cites a {
    color: #2563eb;
    text-decoration: underline;
}

/* ===== リードモーダル ===== */
.grantbot-modal {
    position: fixed;
    inset: 0;
    z-index: 2147483600;
}

.grantbot-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .4);
}

.grantbot-modal-card {
    position: absolute;
    inset: 0;
    margin: auto;
    max-width: 420px;
    width: calc(100vw - 40px);
    max-height: 90vh;
    background: #fff;
    border-radius: 12px;
    padding: 16px 18px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .3);
    overflow: auto;
    font: 14px/1.6 system-ui, -apple-system, "Segoe UI", Roboto,
        "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", "Meiryo",
        sans-serif;
    color: #111827;
}

.grantbot-modal-card h3 {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 600;
}

.grantbot-modal-card p {
    margin: 0 0 12px;
    font-size: 13px;
}

.grantbot-modal-card label {
    display: block;
    font-size: 13px;
    margin: 6px 0;
}

.grantbot-modal-card input[type="text"],
.grantbot-modal-card input[type="tel"],
.grantbot-modal-card input[type="email"],
.grantbot-modal-card input[type="url"] {
    width: 100%;
    margin-top: 4px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    font: inherit;
}

.grantbot-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
}

.grantbot-modal-actions button {
    appearance: none;
    border-radius: 9999px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    border: 1px solid #d1d5db;
    background: #fff;
}

.grantbot-modal-actions #wgc-send {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

.grantbot-modal-hint {
    margin-top: 8px;
    font-size: 11px;
    color: #6b7280;
}

.grantbot-modal-error {
    font-size: 12px;
}

/* ===== インライン リードフォーム ===== */
.grantbot-panel .grantbot-lead {
    margin-top: 6px;
    padding: 10px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid #e5e7eb;
    font-size: 13px;
}

.grantbot-panel .grantbot-lead label {
    display: block;
    margin-bottom: 6px;
}

.grantbot-panel .grantbot-lead input {
    width: 100%;
    margin-top: 2px;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    font: inherit;
}

.grantbot-panel .grantbot-lead .lead-send {
    margin-top: 6px;
    appearance: none;
    border-radius: 9999px;
    border: 0;
    padding: 6px 12px;
    background: #2563eb;
    color: #fff;
    cursor: pointer;
}

/* ===== レスポンシブ微調整 ===== */
@media (min-width: 769px) and (max-width: 1100px) {
    .grantbot-btn {
        right: 30px;
        bottom: 90px;
    }

    .grantbot-panel {
        right: 30px;
        bottom: 160px;
    }
}

@media (max-width: 768px) {
    .grantbot-btn {
        right: 15px !important;
        bottom: 130px !important;
        width: 56px;
        height: 56px;
        /* ← この位置がスマホで一番安全ゾーン */
    }

    .grantbot-panel {
        right: 15px !important;
        bottom: 180px !important;
        /* ボタンより30px上 */
        width: calc(100vw - 30px) !important;
    }

    #return_top {
        right: 15px !important;
    }
}