.ans {
  background:#fafafa;
  border:1px solid #eee;
  border-radius:10px;
  padding:16px;
  white-space: pre-wrap;   /* 改行と空白を保持 */
  font-family: Consolas, "Courier New", monospace; /* 等幅フォント推奨 */
}
.input-controls {
        position: relative; /* fixed を解除 */
        width: 100%;
        box-sizing: border-box;
        background-color: white;
        padding: 10px 0; /* 左右のパディングは親に任せる */
        z-index: 10;
      }
      #message-content {
        margin-bottom: 0;
      }

:root {
  --primary-color: #5c67f2;
  --primary-hover: #5058e5;
  --danger-color: #ff6f61;
  --danger-hover: #ff4f41;
  --success-color: #4CAF50;
  --success-hover: #45a049;
  --button-gradient-end: #4052ff;
  --button-gradient-start: #6b7cff;
  --button-text-color: #ffffff;
  --user-bubble-border: #2a35cc;
  --bot-bubble-border: #81d4fa;
  --bot-bubble-bg: #e1f5fe;
  --chat-bubble-bg-start: #f0f8ff;
  --chat-bubble-bg-end: #d0eafc;
  --bot-text-color: #003049;
  --user-tail-color: #5469f9;

  /* 画面幅に応じた文字サイズ（4.7インチ級の狭い画面で読みやすく収める） */
  --font-chat-bubble: clamp(12px, 2.5vw + 4.5px, 15px);
  --font-chat-label: clamp(11px, 1.2vw + 8px, 14px);
  --font-ui-button: clamp(12.5px, 2.2vw + 6px, 15px);
  --font-body-ui: clamp(13px, 1.8vw + 9px, 16px);
  /* 入力欄: iOS フォーカス時の自動ズームを避ける下限 */
  --font-input-touch: max(16px, var(--font-body-ui));

}
:root.theme-blue  { --primary-color:#5c67f2; --primary-hover:#5058e5; --button-gradient-start:#6b7cff; --button-gradient-end:#4052ff; --user-bubble-border:#2a35cc; --bot-bubble-border:#81d4fa; --bot-bubble-bg:#e1f5fe; --chat-bubble-bg-start:#f0f8ff; --chat-bubble-bg-end:#d0eafc; --bot-text-color:#003049; --user-tail-color:#5469f9; --button-text-color:#ffffff; }
:root.theme-red   { --primary-color:#e53935; --primary-hover:#d32f2f; --button-gradient-start:#ef5350; --button-gradient-end:#b71c1c; --user-bubble-border:#b71c1c; --bot-bubble-border:#ffcdd2; --bot-bubble-bg:#ffebee; --chat-bubble-bg-start:#ffe5e5; --chat-bubble-bg-end:#ffcdd2; --bot-text-color:#880e4f; --user-tail-color:#e53935; --button-text-color:#ffffff; }
:root.theme-green { --primary-color:#4caf50; --primary-hover:#388e3c; --button-gradient-start:#81c784; --button-gradient-end:#388e3c; --user-bubble-border:#2e7d32; --bot-bubble-border:#a5d6a7; --bot-bubble-bg:#e8f5e9; --chat-bubble-bg-start:#e0f2f1; --chat-bubble-bg-end:#a5d6a7; --bot-text-color:#1b5e20; --user-tail-color:#4caf50; --button-text-color:#ffffff; }
:root.theme-yellow{ --primary-color:#fbc02d; --primary-hover:#f9a825; --button-gradient-start:#fff176; --button-gradient-end:#fbc02d; --user-bubble-border:#f57f17; --bot-bubble-border:#fff9c4; --bot-bubble-bg:#fffde7; --chat-bubble-bg-start:#fffde7; --chat-bubble-bg-end:#fff59d; --bot-text-color:#f57f17; --user-tail-color:#fbc02d; --button-text-color:#000000; }
:root.theme-orange{ --primary-color:#fb8c00; --primary-hover:#ef6c00; --button-gradient-start:#ffb74d; --button-gradient-end:#e65100; --user-bubble-border:#e65100; --bot-bubble-border:#ffe0b2; --bot-bubble-bg:#fff3e0; --chat-bubble-bg-start:#ffe0b2; --chat-bubble-bg-end:#ffcc80; --bot-text-color:#bf360c; --user-tail-color:#fb8c00; --button-text-color:#ffffff; }
:root.theme-purple{ --primary-color:#9c27b0; --primary-hover:#7b1fa2; --button-gradient-start:#ba68c8; --button-gradient-end:#6a1b9a; --user-bubble-border:#6a1b9a; --bot-bubble-border:#e1bee7; --bot-bubble-bg:#f3e5f5; --chat-bubble-bg-start:#ede7f6; --chat-bubble-bg-end:#d1c4e9; --bot-text-color:#4a148c; --user-tail-color:#9c27b0; --button-text-color:#ffffff; }
:root.theme-indigo{ --primary-color:#3f51b5; --primary-hover:#303f9f; --button-gradient-start:#7986cb; --button-gradient-end:#283593; --user-bubble-border:#1a237e; --bot-bubble-border:#c5cae9; --bot-bubble-bg:#e8eaf6; --chat-bubble-bg-start:#e3f2fd; --chat-bubble-bg-end:#bbdefb; --bot-text-color:#1a237e; --user-tail-color:#3f51b5; --button-text-color:#ffffff; }
:root.theme-brown { --primary-color:#a1866f; --primary-hover:#7b5e45; --button-gradient-start:#d2b48c; --button-gradient-end:#a1866f; --user-bubble-border:#3e2723; --bot-bubble-border:#a1866f; --bot-bubble-bg:#f5f0e6; --chat-bubble-bg-start:#f5f0e6; --chat-bubble-bg-end:#e0d5c2; --bot-text-color:#3e2f1c; --user-tail-color:#a1866f; --button-text-color:#ffffff; }
:root.theme-white { --primary-color:#cccccc; --primary-hover:#aaaaaa; --button-gradient-start:#f5f5f5; --button-gradient-end:#e0e0e0; --user-bubble-border:#bbbbbb; --bot-bubble-border:#eeeeee; --bot-bubble-bg:#ffffff; --chat-bubble-bg-start:#ffffff; --chat-bubble-bg-end:#f5f5f5; --bot-text-color:#222222; --user-tail-color:#cccccc; --button-text-color:#000000; }
:root.theme-black { --primary-color:#212121; --primary-hover:#000000; --button-gradient-start:#484848; --button-gradient-end:#212121; --user-bubble-border:#000000; --bot-bubble-border:#444444; --bot-bubble-bg:#333333; --chat-bubble-bg-start:#424242; --chat-bubble-bg-end:#212121; --bot-text-color:#ffffff; --user-tail-color:#212121; --button-text-color:#ffffff; }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background-color: #f9f9f9;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            font-size: var(--font-body-ui);
        }
        .chat-container {
            width: 100%;
            max-width: 95%; /* 左右に少し余裕を持たせる */
            margin: 10px auto;
            border: 1px solid #ddd;
            box-shadow: 0 0 20px rgba(0,0,0,0.1);
            padding: 20px;
            background-color: white;
            border-radius: 10px;
            display: flex;
            flex-direction: column;
            height: calc(100vh - 20px); /* 画面の高さに合わせる */
            box-sizing: border-box;
        }
        /* ヘッダー部分のスタイル */
        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }
        .logo {
            height: 50px;
        }
        .user-icon {
            height: 50px;
            margin-left: 10px;
        }
        .bot-icon {
            height: 50px;
            margin-right: 10px;
        }
        #foreignlanguage {
            appearance: none;
            background-color: #fff;
            border: 1px solid #ccc;
            border-radius: 5px;
            padding: 10px;
            font-size: 16px;
            width: 200px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            cursor: pointer;
            transition: border-color 0.3s;
        }
        #foreignlanguage:hover {
            border-color: var(--sticky-theme-primary, var(--primary-color));
        }
        #foreignlanguage:focus {
            outline: none;
            border-color: var(--sticky-theme-primary, var(--primary-color));
        }
        #foreignlanguage::after {
            content: '▼';
            font-size: 12px;
            color: #333;
            position: absolute;
            right: 10px;
            pointer-events: none;
        }
        form {
            display: flex;
            flex-direction: column;
            gap: 10px;
            align-items: flex-start;
            width: 100%;
        }
        input[type="text"] {
            width: 100%;
            padding: 10px;
            font-size: var(--font-input-touch);
            border: 1px solid #ccc;
            border-radius: 5px;
            box-sizing: border-box;
        }
        .form-controls {
            display: flex;
            padding: 5px;
            justify-content: flex-start; /* ボタンを左揃え */
            gap: 10px;
            margin-bottom: 10px; /* ボタンと入力フィールドの間にスペースを追加 */
        }
        button {
            background-color: var(--sticky-theme-primary, var(--primary-color));
            color: white;
        }
        button:hover {
            background-color: var(--sticky-theme-primary-hover, var(--primary-hover));
        }
        .clear-button {
            background-color: var(--sticky-theme-danger-color, var(--danger-color));
            color: white;
            display: none;
        }
        .clear-button:hover {
            background-color: var(--sticky-theme-danger-hover, var(--danger-hover));
        }

        /* message-content: 子の .chat-history-container が残り高さを占有（flex 子は min-height:0 が必須） */
        #message-content {
            flex: 1;
            min-height: 0;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            padding: 15px;
            background-color: #fff;
            border: 2px solid #ccc;
            border-radius: 10px;
            margin-bottom: 15px;
        }
        #message-content::-webkit-scrollbar {
            display: none; /* Chrome等 */
        }
  body::-webkit-scrollbar {
  display: none;
}

html::-webkit-scrollbar {
  display: none;
}      
        
        .chat-history-container {
            flex: 1;
            min-height: 0;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            margin-bottom: 0;
        }

        .chat-history, .translate-result {
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 5px;
            background-color: #f0f0f0;
            overflow-x: auto;
            overflow-y: auto;
            flex: 1;
            min-height: 0;
            margin: 5px;
        }
        .chat-history {
            margin-right: 5px;
        }
        .translate-result {
            display: none;
        }
        select {
            appearance: none;
            background-color: #fff;
            border: 1px solid #ccc;
            border-radius: 5px;
            padding: 10px;
            font-size: 16px;
            width: 200px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            cursor: pointer;
            transition: border-color 0.3s;
        }
        select:hover {
            border-color: var(--sticky-theme-primary, var(--primary-color));
        }
        select:focus {
            outline: none;
            border-color: var(--sticky-theme-primary, var(--primary-color));
        }
        select::after {
            content: '▼';
            font-size: 12px;
            color: #333;
            position: absolute;
            right: 10px;
            pointer-events: none;
        }
        .form-controls .flex-item {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .input-controls {
            display: flex;
            justify-content: flex-end; /* 送信ボタンを右揃え */
            gap: 10px;
            width: 100%;
            align-items: center;
        }
        input[type="text"] {
            flex: 1; /* 入力フィールドが残りのスペースを占有 */
            padding: 15px;
            font-size: var(--font-input-touch);
            border: 1px solid #ccc;
            border-radius: 5px;
            box-sizing: border-box;
            min-width: 0; /* ← 入力欄が狭い場合に縮小されるように */
        }
        .icon {
            margin-right: 5px;
        }
        .highlighted-link {
            color: red !important;
        }
        .highlighted-link:visited {
            color: red !important;
        }

        /* 解決ボタンのスタイルを追加 */
        .solution-buttons-container {
            margin-top: 0;
            display: flex;
            align-items: center;
            gap: 5px;
    flex-wrap: nowrap; /* ← 改行を防止 */
        }
        .solution-buttons-container p {
            margin: 0;
            padding: 0;
        }
        .solution-buttons {
            margin-top: 0;
        }
        .solution-button {
            padding: 5px 10px;
            margin: 5px 5px 5px 0;
            font-size: 14px;
            border: 1px solid var(--sticky-theme-primary, var(--primary-color));
            border-radius: 5px;
            background-color: #fff;
            color: var(--sticky-theme-primary, var(--primary-color));
            cursor: pointer;
        }
        .solution-button:hover {
            background-color: var(--sticky-theme-primary, var(--primary-color));
            color: #fff;
        }

        /* サジェストボタンのスタイル */
        .suggestion-buttons {
            margin-top: 10px;
            clear: both;
            display: block;
        }
        .suggestion-button {
            background-color: var(--sticky-theme-bot-bubble-bg, var(--bot-bubble-bg));
            border: 1px solid var(--sticky-theme-primary, var(--primary-color));
            color: #00529B;
            padding: 5px 10px;
            margin: 5px 5px 5px 0;
            font-size: 14px;
            border: 1px solid var(--sticky-theme-primary, var(--primary-color));
            border-radius: 5px;
            background-color: #fff;
            color: var(--sticky-theme-primary, var(--primary-color));
            cursor: pointer;
            white-space: normal;
            word-break: break-word;
            max-width: 100%;
        }
        .suggestion-button:hover {
            background-color: #bbdefb;
            color: #003366;
            background-color: var(--sticky-theme-primary, var(--primary-color));
            color: #fff;
        }
        .button-buttons {
            margin-top: 10px;
            display: flex;          
            flex-wrap: wrap;        
            gap: 5px;               
        }
        .button-button {
            padding: 5px 10px;
            font-size: 14px;
            border: 1px solid var(--sticky-theme-primary, var(--primary-color));
            border-radius: 5px;
            background-color: #fff;
            color: var(--sticky-theme-button-text-color, var(--button-text-color));
            cursor: pointer;
            white-space: normal;
            word-break: break-word;
        }
        .button-button:hover {
            background-color: var(--sticky-theme-primary, var(--primary-color));
            color: #fff;
        }
        /* 解決ボタンを固定表示 */
        .solution-buttons-container {
            position: fixed;
            bottom: 80px;  
            left: 50%;
            transform: translateX(-50%);
            background-color: white;
            padding: 10px;
            border-radius: 10px;
            box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
            z-index: 1000; 
            white-space: nowrap;
        }
        .solution-button {
            margin: 0 10px;  
            padding: 10px 20px; 
            font-size: 16px;
        }
        /* AI 思考中表示（オーバーレイ） */
        .runtime {
            display: none;
            position: fixed;
            z-index: 9999;
            inset: 0;
            align-items: center;
            justify-content: center;
            padding: 24px;
            box-sizing: border-box;
            background: rgba(15, 23, 42, 0.12);
            backdrop-filter: blur(3px);
            -webkit-backdrop-filter: blur(3px);
        }
        .runtime.show {
            display: flex;
        }
        /* DSP chat_loading_backdrop_blur=False のとき（待機中も背景をぼかさない） */
        .runtime[data-backdrop-blur="0"] {
            backdrop-filter: none;
            -webkit-backdrop-filter: none;
        }

        /* ===============================================
           ここから「LINE風の付箋(吹き出し)」にするためのCSSを追加
           =============================================== */
        /* 質問・回答それぞれを包む要素 */
        .chat-message {
            width: 100%;
            overflow: visible !important;  /* ← スクロールバーを完全に抑制 */
            margin-bottom: 10px;
        }
        /* 「Q」「A」などのラベル */
        .chat-label {
            font-weight: bold;
            margin: 0 0 3px 0;
            font-size: var(--font-chat-label);
        }
        /* 吹き出し共通スタイル (付箋風) */
        .chat-bubble {
            display: inline-block;
            position: relative;
            padding: 10px 15px;
            margin: 5px 0;
            border: 2px solid #A0CF97;
            border-radius: 8px;
            background-color: #DCF8C6;    /* 淡い緑 */
            max-width: 80%;
            word-wrap: break-word;
            box-shadow: 2px 2px 6px rgba(0,0,0,0.1);
        }
        /* ユーザー(質問)は右側 */
        /* Bot(AI回答)は左側 */
        .bot-bubble {
            background-color: var(--sticky-theme-bot-bubble-bg, var(--bot-bubble-bg));
            border: 1px solid var(--sticky-theme-bot-bubble-border, var(--bot-bubble-border));
            color: #000;
            display: inline-block;
            position: relative;
            padding: 8px 10px;
            margin: 2px 0;
            border: 2px solid #f8d36e;   /* 付箋っぽい色合いに */
            border-radius: 8px;
            background-color: #fff9c4;    /* 付箋っぽい淡い黄色 */
            max-width: 80%;
            white-space: pre-line;
            word-wrap: break-word;
            box-shadow: 2px 2px 6px rgba(0,0,0,0.1);
            float: left;
            clear: both;
            margin-right: 10px;
        }
        .bot-bubble {
            background-color: var(--sticky-theme-bot-bubble-bg, var(--bot-bubble-bg)) !important;
            border: 1px solid var(--sticky-theme-bot-bubble-border, var(--bot-bubble-border)) !important;
            color: #000 !important;
        }
        .chat-user {
            text-align: right; /* 全体を右寄せ */
        }
        .chat-bot {
            text-align: left;  /* 全体を左寄せ */
        }

        /* スマホ相当：付箋を横いっぱいに（480 超の縦向き・横持ちも含む） */
        @media screen and (max-width: 480px),
               screen and (max-width: 1024px) and (max-height: 500px),
               screen and (orientation: portrait) and (max-width: 1024px) {
            .chat-bubble,
            .bot-bubble {
                max-width: 100%;
            }
        }
    
button,
.clear-button,
.solution-button,
.suggestion-button,
.button-button {
    padding: 12px 18px;
    font-size: var(--font-ui-button);
    font-weight: bold;
    border: none;
    border-radius: 25px;
    background: linear-gradient(145deg, var(--sticky-theme-button-gradient-start, var(--button-gradient-start)), var(--sticky-theme-button-gradient-end, var(--button-gradient-end)));
    color: var(--sticky-theme-button-text-color, var(--button-text-color));
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease-in-out;
}

button:hover,
.clear-button:hover,
.solution-button:hover,
.suggestion-button:hover,
.button-button:hover {
    background: linear-gradient(145deg, var(--sticky-theme-button-gradient-end, var(--button-gradient-end)), var(--sticky-theme-user-bubble-border, var(--user-bubble-border)));
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.5);
    transform: translateY(-2px);
}

/* 高級感のある吹き出しスタイル */
.chat-bubble {
    padding: 14px 20px;
    border-radius: 10px;
    font-size: var(--font-chat-bubble);
    font-weight: 500;
    background: linear-gradient(145deg, var(--sticky-theme-chat-bubble-bg-start, var(--chat-bubble-bg-start)), var(--sticky-theme-chat-bubble-bg-end, var(--chat-bubble-bg-end)));
    border: 1px solid #c3e0fa;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease-in-out;
}

/* ユーザー側（右）・質問付箋 - パラメータ(sticky_user_style)で上書き可 */
.user-bubble {
    background: var(--sticky-user-bg, linear-gradient(145deg, var(--sticky-theme-button-gradient-end, var(--button-gradient-end)), var(--sticky-theme-button-gradient-start, var(--button-gradient-start)))) !important;
    color: var(--sticky-user-text, var(--sticky-theme-button-text-color, var(--button-text-color))) !important;
    border: 1px solid var(--sticky-user-border, var(--sticky-theme-user-bubble-border, var(--user-bubble-border)));
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    position: relative;
    overflow: visible !important;  /* ← スクロールバー完全非表示 */
    max-height: none !important;
}
.user-bubble a {
    color: var(--sticky-user-link, var(--sticky-theme-user-bubble-border, var(--user-bubble-border, #2a35cc)));
}
.user-bubble a:visited {
    color: var(--sticky-user-link-visited, var(--sticky-user-link, var(--sticky-theme-user-bubble-border, var(--user-bubble-border, #2a35cc))));
}

/* Bot側（左）・回答付箋 - パラメータ(sticky_bot_style)で上書き可 */
.bot-bubble {
    background: var(--sticky-bot-bg, linear-gradient(145deg, var(--sticky-theme-bot-bubble-bg, var(--bot-bubble-bg)), #c0e7ff));
    border: 1px solid var(--sticky-bot-border, var(--sticky-theme-bot-bubble-border, var(--bot-bubble-border)));
    color: var(--sticky-bot-text, var(--bot-text-color));
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}
/* リンクは枠線色（多くのテーマで薄い）にしない。テーマの primary でコントラスト確保 */
.bot-bubble a {
    color: var(--sticky-bot-link, var(--sticky-theme-primary, var(--primary-color, #1565c0)));
}
.bot-bubble a:visited {
    color: var(--sticky-bot-link-visited, var(--sticky-bot-link, var(--sticky-theme-primary, var(--primary-color, #1565c0))));
}
.bot-bubble a:hover {
    color: var(--sticky-bot-link, var(--sticky-theme-primary-hover, var(--primary-hover, #0d47a1)));
    text-decoration: underline;
}
.bot-bubble a:visited:hover {
    color: var(--sticky-bot-link-visited, var(--sticky-bot-link, var(--sticky-theme-primary-hover, var(--primary-hover, #0d47a1))));
    text-decoration: underline;
}

/* Markdown が「回答：」「出典：」等を h1〜h6 にしたとき、ブラウザ既定の巨大見出しを抑える */
.bot-bubble :where(h1, h2, h3, h4, h5, h6) {
  font-size: 1em;
  font-weight: 700;
  line-height: 1.45;
  margin: 0.45em 0 0.3em;
}
.bot-bubble :where(h1, h2, h3, h4, h5, h6):first-child {
  margin-top: 0;
}

#message-content {
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}
    
.form-controls,
.input-controls,
.button-buttons,
.solution-buttons-container {
    flex-wrap: wrap;
}

button,
.clear-button,
.solution-button,
.suggestion-button,
.button-button {
    max-width: 100%;
    word-break: break-word;
}
.solution-buttons-container {
  background-color: transparent !important;
  box-shadow: none;
}

@media screen and (max-width: 480px) {
    .form-controls,
    .input-controls,
    .button-buttons,
    .solution-buttons-container {
        flex-direction: column;
        align-items: stretch;
    }

    button,
    .clear-button,
    .solution-button,
    .suggestion-button,
    .button-button {
        white-space: normal;
        word-break: break-word;
        width: 100%;
        max-width: 100%; 
    }

    input[type="text"] {
        width: 100%;
    }
}
.message-container {
  display: flex;
  align-items: center; /* 垂直中央揃え */
  justify-content: flex-start; /* 左から並べる */
}
/* 質問付箋（ユーザー側）：アイコンをバブルの右に表示し、全体を右寄せ（ブルー同様） */
.message-container--user,
.message-container:has(.chat-user) {
  justify-content: flex-end;
  flex-direction: row;
}
.message-container--user .user-icon,
.message-container:has(.chat-user) .user-icon {
  margin-left: 10px;
  margin-right: 0;
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}
/* サーバー生成HTMLでアイコンが div で包まれている場合 */
.message-container:has(.chat-user) > div:last-child {
  flex-shrink: 0;
}
.bot-bubble::before {
    content: "";
    position: absolute;
    top: 50%;
    left: -14px;
    transform: translateY(-50%);
    border-top: 14px solid transparent;
    border-bottom: 14px solid transparent;
    border-right: 14px solid var(--sticky-bot-border, var(--sticky-theme-bot-bubble-border, var(--bot-bubble-border))); /* ← 枠線色 */
    z-index: 0;
}

.bot-bubble::after {
    content: "";
    position: absolute;
    top: 50%;
    left: -12px;
    transform: translateY(-50%);
    border-top: 12px solid transparent;
    border-bottom: 12px solid transparent;
    border-right: 12px solid var(--sticky-bot-bg, var(--sticky-theme-bot-bubble-bg, var(--bot-bubble-bg))); /* ← 背景色 */
    z-index: 1;
}

/* ユーザーのしっぽ（背景と完全一体化） */
.user-bubble::before {
  display: none;
}
.user-bubble::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -16px;
  transform: translateY(-50%);
  width: 16px;
  height: 24px;
  background-color: var(--sticky-user-border, var(--sticky-theme-user-tail-color, var(--user-tail-color)));  /* 枠線色に合わせる */
  clip-path: polygon(100% 50%, 0% 0%, 0% 100%);
  z-index: 1;
}

.solution-buttons-container {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
}

.solution-button {
  background-color: #3B82F6; /* 青系 */
  color: white;
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: bold;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.3s;
}

.solution-button:hover {
  background-color: #2563eb; /* hoverで濃い青 */
}
    .solution-buttons-container {
      display: none;
      position: fixed;
      bottom: 80px;
      left: 50%;
      transform: translateX(-50%);
      z-index: 1000;
      background-color: white;
      border-radius: 10px;
      padding: 10px;
      gap: 10px;
      justify-content: center;
    }

#chat-history {
  -ms-overflow-style: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto;
  max-height: none;
  /* 付箋右側のユーザーアイコン（約48px+余白）が領域外に切れないように */
  padding-right: 64px;
  box-sizing: border-box;
}
@media screen and (max-width: 480px),
       screen and (max-width: 1024px) and (max-height: 500px),
       screen and (orientation: portrait) and (max-width: 1024px) {
  .chat-bot .message-container {
    flex-direction: column !important;
    align-items: flex-start !important;
  }

  .bot-icon {
    margin-bottom: 6px;
    height: 48px;
  }

  .bot-bubble::before {
    content: "";
    position: absolute;
    top: -14px;  /* ← 上に配置 */
    left: 20px;  /* ← バブルの左寄り中央に */
    border-left: 14px solid transparent;
    border-right: 14px solid transparent;
    border-bottom: 14px solid var(--sticky-bot-border, var(--sticky-theme-bot-bubble-border, var(--bot-bubble-border)));
    z-index: 0;
  }

  .bot-bubble::after {
    content: "";
    position: absolute;
    top: -12px;
    left: 22px;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-bottom: 12px solid var(--sticky-bot-bg, var(--sticky-theme-bot-bubble-bg, var(--bot-bubble-bg)));
    z-index: 1;
  }
}
/* ボットのアイコンとバブルを縦並びにする：PC・スマホ共通 */
.chat-bot .message-container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* ボットアイコンの調整 */
.bot-icon {
  margin-bottom: 6px;
  height: 48px;
}

/* 吹き出しのしっぽ：スマホと同じ見た目をPCにも適用 */
.bot-bubble::before {
  content: "";
  position: absolute;
  top: -14px;  /* 上に出す */
  left: 20px;  /* 横位置調整（バブルの左寄り中央） */
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-bottom: 14px solid var(--sticky-bot-border, var(--sticky-theme-bot-bubble-border, var(--bot-bubble-border)));
  z-index: 0;
}

.bot-bubble::after {
  content: "";
  position: absolute;
  top: -12px;
  left: 22px;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-bottom: 12px solid var(--sticky-bot-bg, var(--sticky-theme-bot-bubble-bg, var(--bot-bubble-bg)));
  z-index: 1;
}

/* チャットローディング（設定 chat_loading_spinner で .chat-loading--* を切替） */
.chat-loading {
  --chat-loading-main-color: var(--chat-loading-character-color, #4338ca);
  --chat-loading-main-color-hover: color-mix(in srgb, var(--chat-loading-main-color), #000 15%);
  --sticky-theme-button-gradient-start: var(--chat-loading-main-color);
  --sticky-theme-button-gradient-end: var(--chat-loading-main-color);
}

.chat-loading__panel {
  text-align: center;
  max-width: 280px;
  padding: 28px 32px 24px;
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.96));
  box-shadow:
    0 4px 24px rgba(15, 23, 42, 0.12),
    0 0 0 1px color-mix(in srgb, var(--chat-loading-main-color), transparent 92%);
  color: #334155;
}

.chat-loading__character-photo {
  margin: 0 auto 14px;
  max-width: 140px;
}

.chat-loading__character-photo img {
  display: block;
  width: 100%;
  max-height: 160px;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.08);
}

.chat-loading__panel:has(.chat-loading__character-photo) .chat-loading__visual {
  display: none !important;
}  

.chat-loading__visual {
  display: none !important;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  margin: 0 auto 16px;
  width: 100%;
  box-sizing: border-box;
}

.chat-loading--ai-thinking .chat-loading__visual--ai-thinking,
.chat-loading--classic .chat-loading__visual--classic,
.chat-loading--dots .chat-loading__visual--dots,
.chat-loading--pulse .chat-loading__visual--pulse,
.chat-loading--bars .chat-loading__visual--bars,
.chat-loading--minimal .chat-loading__visual--minimal,
.chat-loading--neural .chat-loading__visual--neural,
.chat-loading--dual-ring .chat-loading__visual--dual-ring,
.chat-loading--spark-orbit .chat-loading__visual--spark-orbit,
.chat-loading--synapse .chat-loading__visual--synapse,
.chat-loading--cortex .chat-loading__visual--cortex,
.chat-loading--robot-face .chat-loading__visual--robot-face,
.chat-loading--robot-visor .chat-loading__visual--robot-visor,
.chat-loading--robot-gears .chat-loading__visual--robot-gears,
.chat-loading--robot-antenna .chat-loading__visual--robot-antenna,
.chat-loading--robot-tread .chat-loading__visual--robot-tread,
.chat-loading--chatbot-bubble .chat-loading__visual--chatbot-bubble,
.chat-loading--chatbot-assistant .chat-loading__visual--chatbot-assistant,
.chat-loading--chatbot-voice .chat-loading__visual--chatbot-voice,
.chat-loading--chatbot-chip .chat-loading__visual--chatbot-chip,
.chat-loading--chatbot-active .chat-loading__visual--chatbot-active,
.chat-loading--llm-brain .chat-loading__visual--llm-brain,
.chat-loading--llm-layers .chat-loading__visual--llm-layers,
.chat-loading--llm-tokens .chat-loading__visual--llm-tokens,
.chat-loading--llm-mesh .chat-loading__visual--llm-mesh,
.chat-loading--llm-nucleus .chat-loading__visual--llm-nucleus,
.chat-loading--cat-face .chat-loading__visual--cat-face,
.chat-loading--cat-nap .chat-loading__visual--cat-nap {
  display: flex !important;
}

/* --- ai-thinking --- */
.ai-thinking__visual {
  position: relative;
  width: 64px;
  height: 64px;
  margin: 0;
}
.ai-thinking__ring {
  position: absolute;
  inset: 0;
  animation: ai-thinking-orbit 2.4s linear infinite;
}
.ai-thinking__ring span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 11px;
  height: 11px;
  margin: -5.5px 0 0 -5.5px;
  border-radius: 50%;
  background: var(--chat-loading-main-color);
  box-shadow: 0 0 10px color-mix(in srgb, var(--chat-loading-main-color), transparent 55%);
  opacity: 0.95;
}
.ai-thinking__ring span:nth-child(1) {
  transform: rotate(0deg) translateY(-26px);
}
.ai-thinking__ring span:nth-child(2) {
  transform: rotate(120deg) translateY(-26px);
}
.ai-thinking__ring span:nth-child(3) {
  transform: rotate(240deg) translateY(-26px);
}
.ai-thinking__core {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 35% 35%,
    var(--sticky-theme-button-gradient-start, #8b9aff),
    var(--chat-loading-main-color) 55%,
    var(--chat-loading-main-color-hover)
  );
  animation: ai-thinking-pulse 1.25s ease-in-out infinite;
  z-index: 1;
}

/* --- classic / minimal --- */
.spinner-classic {
  width: 56px;
  height: 56px;
  border: 5px solid rgba(15, 23, 42, 0.1);
  border-top-color: var(--chat-loading-main-color);
  border-radius: 50%;
  animation: chat-loading-spin 0.88s linear infinite;
  box-sizing: border-box;
}
.spinner-minimal {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(15, 23, 42, 0.12);
  border-top-color: var(--chat-loading-main-color);
  border-radius: 50%;
  animation: chat-loading-spin 0.6s linear infinite;
  box-sizing: border-box;
}

/* --- dots --- */
.chat-loading__dots {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  height: 48px;
}
.chat-loading__dots span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--chat-loading-main-color);
  animation: chat-loading-dot-bounce 1.05s ease-in-out infinite;
  opacity: 0.92;
}
.chat-loading__dots span:nth-child(2) {
  animation-delay: 0.16s;
}
.chat-loading__dots span:nth-child(3) {
  animation-delay: 0.32s;
}

/* --- pulse (同心円) --- */
.chat-loading__pulse {
  position: relative;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-loading__pulse-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--chat-loading-main-color);
  opacity: 0;
  animation: chat-loading-pulse-ring 1.8s ease-out infinite;
}
.chat-loading__pulse-ring:nth-child(2) {
  animation-delay: 0.45s;
}
.chat-loading__pulse-ring:nth-child(3) {
  animation-delay: 0.9s;
}

/* --- bars --- */
.chat-loading__bars {
  display: flex;
  gap: 5px;
  align-items: flex-end;
  justify-content: center;
  height: 44px;
}
.chat-loading__bars span {
  width: 6px;
  height: 8px;
  border-radius: 3px;
  background: var(--chat-loading-main-color);
  animation: chat-loading-bar 0.95s ease-in-out infinite;
  transform-origin: bottom center;
}
.chat-loading__bars span:nth-child(1) {
  animation-delay: 0s;
}
.chat-loading__bars span:nth-child(2) {
  animation-delay: 0.1s;
}
.chat-loading__bars span:nth-child(3) {
  animation-delay: 0.2s;
}
.chat-loading__bars span:nth-child(4) {
  animation-delay: 0.3s;
}
.chat-loading__bars span:nth-child(5) {
  animation-delay: 0.4s;
}

/* --- neural（ニューラル：周回ノード＋中心コア） --- */
.chat-loading__neural {
  position: relative;
  width: 56px;
  height: 56px;
}
.chat-loading__neural-orbit {
  position: absolute;
  inset: 0;
  animation: chat-loading-neural-orbit 3.4s linear infinite;
}
.chat-loading__neural-orbit span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 9px;
  height: 9px;
  margin: -4.5px 0 0 -4.5px;
  border-radius: 50%;
  background: var(--chat-loading-main-color);
  box-shadow: 0 0 8px color-mix(in srgb, var(--chat-loading-main-color), transparent 55%);
  animation: chat-loading-neural-glow 1.15s ease-in-out infinite;
}
.chat-loading__neural-orbit span:nth-child(1) {
  transform: rotate(0deg) translateY(-22px);
  animation-delay: 0s;
}
.chat-loading__neural-orbit span:nth-child(2) {
  transform: rotate(60deg) translateY(-22px);
  animation-delay: 0.12s;
}
.chat-loading__neural-orbit span:nth-child(3) {
  transform: rotate(120deg) translateY(-22px);
  animation-delay: 0.24s;
}
.chat-loading__neural-orbit span:nth-child(4) {
  transform: rotate(180deg) translateY(-22px);
  animation-delay: 0.36s;
}
.chat-loading__neural-orbit span:nth-child(5) {
  transform: rotate(240deg) translateY(-22px);
  animation-delay: 0.48s;
}
.chat-loading__neural-orbit span:nth-child(6) {
  transform: rotate(300deg) translateY(-22px);
  animation-delay: 0.6s;
}
.chat-loading__neural-core {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 30% 30%,
    var(--sticky-theme-button-gradient-start, #8b9aff),
    var(--chat-loading-main-color)
  );
  z-index: 2;
  animation: ai-thinking-pulse 1.2s ease-in-out infinite;
  box-shadow: 0 0 12px color-mix(in srgb, var(--chat-loading-main-color), transparent 65%);
}

/* --- dual-ring（二重リング逆回転） --- */
.chat-loading__dual-ring {
  position: relative;
  width: 56px;
  height: 56px;
}
.chat-loading__dual-ring-outer {
  position: absolute;
  left: 0;
  top: 0;
  width: 54px;
  height: 54px;
  border: 3px dashed var(--chat-loading-main-color);
  border-radius: 50%;
  box-sizing: border-box;
  animation: chat-loading-spin 2.1s linear infinite;
}
.chat-loading__dual-ring-inner {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border: 2px dashed var(--chat-loading-main-color-hover);
  border-radius: 50%;
  box-sizing: border-box;
  opacity: 0.82;
  animation: chat-loading-spin-reverse 1.35s linear infinite;
}

/* --- spark-orbit（ひし形スパークの周回） --- */
.chat-loading__spark-orbit {
  position: relative;
  width: 56px;
  height: 56px;
  animation: chat-loading-spin 3.8s linear infinite;
}
.chat-loading__spark-orbit span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  background: var(--chat-loading-main-color);
  border-radius: 2px;
  box-shadow: 0 0 10px color-mix(in srgb, var(--chat-loading-main-color), transparent 45%);
}
.chat-loading__spark-orbit span:nth-child(1) {
  transform: rotate(0deg) translateY(-21px) rotate(45deg);
}
.chat-loading__spark-orbit span:nth-child(2) {
  transform: rotate(90deg) translateY(-21px) rotate(45deg);
}
.chat-loading__spark-orbit span:nth-child(3) {
  transform: rotate(180deg) translateY(-21px) rotate(45deg);
}
.chat-loading__spark-orbit span:nth-child(4) {
  transform: rotate(270deg) translateY(-21px) rotate(45deg);
}

/* --- synapse（ノード列＋走る信号） --- */
.chat-loading__synapse {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 22px;
  min-width: 112px;
  padding: 0 4px;
}
.chat-loading__synapse > span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--chat-loading-main-color);
  opacity: 0.4;
  animation: chat-loading-synapse-node 1.35s ease-in-out infinite;
}
.chat-loading__synapse > span:nth-child(1) {
  animation-delay: 0s;
}
.chat-loading__synapse > span:nth-child(2) {
  animation-delay: 0.12s;
}
.chat-loading__synapse > span:nth-child(3) {
  animation-delay: 0.24s;
}
.chat-loading__synapse > span:nth-child(4) {
  animation-delay: 0.36s;
}
.chat-loading__synapse > span:nth-child(5) {
  animation-delay: 0.48s;
}
.chat-loading__synapse-beam {
  position: absolute;
  left: -8px;
  top: 50%;
  width: 40px;
  height: 14px;
  margin-top: -7px;
  border-radius: 7px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(92, 103, 242, 0.25),
    var(--chat-loading-main-color),
    rgba(92, 103, 242, 0.25),
    transparent
  );
  animation: chat-loading-synapse-beam 1.65s ease-in-out infinite;
  pointer-events: none;
}

/* --- cortex（走査する脳波風ライン） --- */
.chat-loading__cortex {
  display: flex;
  flex-direction: column;
  gap: 7px;
  align-items: center;
  justify-content: center;
  width: 56px;
}
.chat-loading__cortex-line {
  display: block;
  width: 48px;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(
    90deg,
    rgba(92, 103, 242, 0.12),
    rgba(92, 103, 242, 0.12) 35%,
    var(--chat-loading-main-color) 50%,
    rgba(92, 103, 242, 0.12) 65%,
    rgba(92, 103, 242, 0.12)
  );
  background-size: 220% 100%;
  animation: chat-loading-cortex-scan 1.85s linear infinite;
}
.chat-loading__cortex-line:nth-child(2) {
  animation-delay: 0.22s;
  width: 40px;
}
.chat-loading__cortex-line:nth-child(3) {
  animation-delay: 0.44s;
  width: 44px;
}

/* キャラクター系スピナーはエリアを広げて少し大きく表示 */
.chat-loading__visual--character {
  min-height: 110px !important;
  margin-bottom: 24px;
  /* キャラクター共通：ふわふわとした浮遊感を追加 */
  animation: character-bobbing 2.5s ease-in-out infinite;
}

@keyframes character-bobbing {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* --- ロボット風スピナー（キャラ詳細・拡大・可愛く） --- */
.chat-loading__robot-face {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.chat-loading__robot-face__antenna {
  position: relative;
  width: 5px;
  height: 14px;
  margin-bottom: 3px;
  border-radius: 3px;
  background: linear-gradient(
    180deg,
    var(--chat-loading-main-color-hover),
    var(--chat-loading-main-color)
  );
}
.chat-loading__robot-face__antenna::after {
  content: "";
  position: absolute;
  top: -9px;
  left: 50%;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 35% 30%,
    #fff 0%,
    var(--chat-loading-main-color-hover) 45%,
    var(--chat-loading-main-color) 100%
  );
  animation: robot-face-antenna-pulse 1.1s ease-in-out infinite;
  box-shadow: 0 0 12px color-mix(in srgb, var(--chat-loading-main-color), transparent 40%);
}
.chat-loading__robot-face__row {
  display: flex;
  align-items: center;
  gap: 5px;
}
.chat-loading__robot-face__bolt {
  width: 8px;
  height: 16px;
  border-radius: 4px;
  border: 2px solid var(--chat-loading-main-color);
  background: color-mix(in srgb, var(--chat-loading-main-color), transparent 85%);
}
.chat-loading__robot-face__head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 62px;
  height: 50px;
  box-sizing: border-box;
  border: 3px solid var(--chat-loading-main-color);
  border-radius: 18px; /* より丸く */
  background: linear-gradient(165deg, #fff 0%, rgba(255, 255, 255, 0.8) 20%, color-mix(in srgb, var(--chat-loading-main-color), transparent 92%) 100%);
  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, 0.8),
    0 4px 15px rgba(15, 23, 42, 0.1);
}
.chat-loading__robot-face__cheek {
  position: absolute;
  bottom: 10px;
  width: 11px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 140, 160, 0.45);
  filter: blur(1px);
}
.chat-loading__robot-face__cheek--l { left: 6px; }
.chat-loading__robot-face__cheek--r { right: 6px; }

.chat-loading__robot-face__eye {
  position: relative;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #2d2a28;
  animation: robot-face-eye 3s ease-in-out infinite;
}
.chat-loading__robot-face__eye::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fff; /* キラキラの瞳 */
}
.chat-loading__robot-face__neck {
  width: 32px;
  height: 8px;
  margin-top: 2px;
  border-radius: 4px;
  border: 2px solid var(--chat-loading-main-color);
  border-top: none;
  background: color-mix(in srgb, var(--chat-loading-main-color), transparent 90%);
}
.chat-loading__robot-face__mouth {
  width: 22px;
  height: 8px; /* 笑顔の弧に */
  margin-top: 6px;
  border: 2px solid transparent;
  border-bottom-color: var(--chat-loading-main-color);
  border-radius: 0 0 12px 12px;
}

/* robot-visor = ザクII頭部（色は他キャラスピナー同様 --chat-loading-main-color） */
.chat-loading__robot-visor {
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-loading__zaku-head {
  width: 76px;
  height: 90px;
  max-width: 100%;
  flex-shrink: 0;
  display: block;
  overflow: visible;
}
.chat-loading__zaku-pipe {
  fill: none;
  stroke: color-mix(in srgb, var(--chat-loading-main-color), #ffffff 42%);
}
.chat-loading__zaku-pipe-rib {
  fill: none;
  stroke: color-mix(in srgb, var(--chat-loading-main-color), #000000 28%);
}
.chat-loading__zaku-helmet {
  fill: var(--chat-loading-main-color);
  stroke: color-mix(in srgb, var(--chat-loading-main-color), #000000 22%);
}
.chat-loading__zaku-helmet-highlight {
  fill: #ffffff;
  opacity: 0.16;
}
.chat-loading__zaku-visor {
  fill: color-mix(in srgb, var(--chat-loading-main-color), #000000 82%);
}
.chat-loading__zaku-eye-lens {
  fill: color-mix(in srgb, var(--chat-loading-main-color-hover), #ffffff 48%);
}
.chat-loading__zaku-eye-glint {
  fill: #ffffff;
  opacity: 0.45;
}
.chat-loading__zaku-mouth {
  fill: color-mix(in srgb, var(--chat-loading-main-color), #000000 18%);
  stroke: color-mix(in srgb, var(--chat-loading-main-color), #000000 35%);
}
.chat-loading__zaku-mouth-slits {
  stroke: color-mix(in srgb, var(--chat-loading-main-color), #000000 55%);
}
/* モノアイの動きは SVG 内 SMIL（<animateTransform>） */

.chat-loading__robot-gears {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.chat-loading__robot-gears__wheel {
  width: 36px;
  height: 36px;
  box-sizing: border-box;
  border-radius: 50%;
  border: 3px dashed var(--chat-loading-main-color);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--chat-loading-main-color), transparent 88%);
}
.chat-loading__robot-gears__wheel--a {
  animation: chat-loading-spin 1.75s linear infinite;
}
.chat-loading__robot-gears__wheel--b {
  border-color: var(--chat-loading-main-color-hover);
  animation: chat-loading-spin-reverse 1.25s linear infinite;
}

.chat-loading__robot-antenna {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.chat-loading__robot-antenna__ball {
  width: 14px;
  height: 14px;
  margin-bottom: 2px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, #fff 0%, var(--chat-loading-main-color-hover) 40%, var(--chat-loading-main-color) 100%);
  animation: ai-thinking-pulse 1.05s ease-in-out infinite;
  box-shadow:
    0 0 12px color-mix(in srgb, var(--chat-loading-main-color), transparent 45%),
    inset 0 -3px 5px rgba(0, 0, 0, 0.15);
}
.chat-loading__robot-antenna__stem {
  width: 3px;
  height: 11px;
  border-radius: 2px;
  background: linear-gradient(
    180deg,
    var(--chat-loading-main-color-hover),
    var(--chat-loading-main-color)
  );
}
.chat-loading__robot-antenna__head {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 30px;
  margin-top: 3px;
  box-sizing: border-box;
  border: 3px solid var(--chat-loading-main-color);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.25), color-mix(in srgb, var(--chat-loading-main-color), transparent 92%));
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4);
}
.chat-loading__robot-antenna__visor {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 38px;
  height: 18px;
  border-radius: 5px;
  background: rgba(15, 23, 42, 0.12);
  border: 1px solid color-mix(in srgb, var(--chat-loading-main-color), transparent 65%);
}
.chat-loading__robot-antenna__eye {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, #fff, var(--chat-loading-main-color));
  animation: robot-antenna-led 1.05s ease-in-out infinite;
  box-shadow: 0 0 6px color-mix(in srgb, var(--chat-loading-main-color), transparent 50%);
}
.chat-loading__robot-antenna__eye:nth-child(2) {
  animation-delay: 0.15s;
}
.chat-loading__robot-antenna__torso {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 5px;
  margin-top: -2px;
}
.chat-loading__robot-antenna__arm {
  width: 8px;
  height: 14px;
  margin-bottom: 2px;
  border-radius: 3px;
  border: 2px solid var(--chat-loading-main-color);
  background: linear-gradient(180deg, color-mix(in srgb, var(--chat-loading-main-color), transparent 82%), color-mix(in srgb, var(--chat-loading-main-color), transparent 95%));
}
.chat-loading__robot-antenna__body {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 50px;
  height: 24px;
  padding: 0 12px;
  box-sizing: border-box;
  border: 3px solid var(--chat-loading-main-color);
  border-radius: 0 0 12px 12px;
  border-top: none;
  background: linear-gradient(180deg, color-mix(in srgb, var(--chat-loading-main-color), transparent 90%), color-mix(in srgb, var(--chat-loading-main-color), transparent 97%));
}
.chat-loading__robot-antenna__body span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--chat-loading-main-color);
  opacity: 0.35;
  animation: robot-antenna-led 1.1s ease-in-out infinite;
  box-shadow: 0 0 6px color-mix(in srgb, var(--chat-loading-main-color), transparent 65%);
}
.chat-loading__robot-antenna__body span:nth-child(2) {
  animation-delay: 0.18s;
}
.chat-loading__robot-antenna__body span:nth-child(3) {
  animation-delay: 0.36s;
}

/* robot-tread = Android ロボ風シルエット（添付イメージ：ドーム頭・アンテナ・白目・胴・腕・脚） */
.chat-loading__robot-tread {
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-loading__robot-tread-svg {
  width: 72px;
  height: 82px;
  max-width: 100%;
  flex-shrink: 0;
  display: block;
  overflow: visible;
  animation: robot-android-soft-pulse 1.6s ease-in-out infinite;
}
.chat-loading__android-fill {
  fill: var(--chat-loading-main-color);
}
.chat-loading__android-antenna {
  fill: none;
  stroke: var(--chat-loading-main-color);
  stroke-width: 3.8;
  stroke-linecap: round;
}
.chat-loading__android-eye {
  fill: #ffffff;
  animation: robot-android-eye-blink 2.9s ease-in-out infinite;
}
.chat-loading__android-eye--r {
  animation-delay: 0.05s;
}

/* --- chatbot-bubble = ヘッドセット顔（白いマスク面・テーマ色の目がまばたき） --- */
.chat-loading__chatbot-bubble {
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 3px 10px color-mix(in srgb, var(--chat-loading-main-color), transparent 85%));
}
.chat-loading__chatbot-bubble-svg {
  width: 96px;
  height: 96px;
  max-width: 100%;
  flex-shrink: 0;
  display: block;
  overflow: visible;
  animation: chatbot-bubble-soft-pulse 1.55s ease-in-out infinite;
}
.chat-loading__bubblebot-chassis {
  fill: var(--chat-loading-main-color);
  stroke: none;
}
.chat-loading__bubblebot-ring {
  fill: none;
  stroke: #ffffff;
  stroke-width: 5.2;
}
.chat-loading__bubblebot-face {
  fill: #ffffff;
  stroke: none;
}
.chat-loading__bubblebot-eye {
  fill: color-mix(in srgb, var(--chat-loading-main-color), #000000 38%);
  stroke: none;
  transform-box: fill-box;
  transform-origin: center;
  animation: bubblebot-blink 2.85s ease-in-out infinite;
}
.chat-loading__bubblebot-eye--r {
  animation-delay: 0.05s;
}
.chat-loading__bubblebot-mic-boom {
  stroke: var(--chat-loading-main-color);
  stroke-width: 5.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chat-loading__bubblebot-mic-tip {
  fill: var(--chat-loading-main-color);
  stroke: none;
}

.chat-loading__chatbot-assistant {
  position: relative;
  width: 96px;
  height: 96px;
}
.chat-loading__chatbot-assistant__silhouette {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}
.chat-loading__chatbot-assistant__ear {
  flex: 0 0 auto;
  width: 11px;
  height: 24px;
  border-radius: 6px;
  border: 2px solid var(--chat-loading-main-color);
  background: linear-gradient(180deg, color-mix(in srgb, var(--chat-loading-main-color), transparent 78%), color-mix(in srgb, var(--chat-loading-main-color), transparent 94%));
  box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.3);
}
.chat-loading__chatbot-assistant__ear--l {
  margin-right: -3px;
  border-radius: 8px 4px 4px 8px;
}
.chat-loading__chatbot-assistant__ear--r {
  margin-left: -3px;
  border-radius: 4px 8px 8px 4px;
}
.chat-loading__chatbot-assistant__inner {
  position: relative;
  flex: 0 0 auto;
  width: 70px;
  height: 70px;
}
.chat-loading__chatbot-assistant__ring {
  position: absolute;
  inset: 0;
  border: 3px dashed var(--chat-loading-main-color);
  border-radius: 50%;
  opacity: 0.6;
  animation: chat-loading-spin 3.8s linear infinite;
}
.chat-loading__chatbot-assistant__face {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  box-sizing: border-box;
  border: 3px solid var(--chat-loading-main-color);
  border-radius: 50%;
  background: radial-gradient(
    circle at 35% 28%,
    #fff 0%,
    rgba(255, 252, 248, 1) 40%,
    color-mix(in srgb, var(--chat-loading-main-color), transparent 95%) 100%
  );
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  z-index: 1;
  box-shadow:
    inset 0 2px 6px rgba(255, 255, 255, 0.5),
    0 4px 14px color-mix(in srgb, var(--chat-loading-main-color), transparent 85%);
}
.chat-loading__chatbot-assistant__blush {
  position: absolute;
  bottom: 12px;
  width: 12px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 160, 180, 0.5); /* ピンクを少し強調 */
  filter: blur(1.5px);
  pointer-events: none;
}
.chat-loading__chatbot-assistant__blush--l {
  left: 6px;
}
.chat-loading__chatbot-assistant__blush--r {
  right: 6px;
}
.chat-loading__chatbot-assistant__eyes {
  display: flex;
  gap: 14px;
}
.chat-loading__chatbot-assistant__eyes span {
  position: relative;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #fff 0%, var(--chat-loading-main-color) 45%, color-mix(in srgb, var(--chat-loading-main-color), #000 40%) 100%);
  animation: chatbot-assistant-blink 2.8s ease-in-out infinite;
  box-shadow: 0 2px 6px color-mix(in srgb, var(--chat-loading-main-color), transparent 65%);
}
.chat-loading__chatbot-assistant__eyes span::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
}
.chat-loading__chatbot-assistant__eyes span:nth-child(2) {
  animation-delay: 0.1s;
}
.chat-loading__chatbot-assistant__mouth {
  width: 20px;
  height: 10px;
  border: 3px solid transparent;
  border-bottom-color: var(--chat-loading-main-color);
  border-radius: 0 0 18px 18px;
  margin-top: -3px;
}

.chat-loading__chatbot-voice {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 5px;
  height: 44px;
  padding: 0 4px;
}
.chat-loading__chatbot-voice span {
  width: 5px;
  min-height: 8px;
  border-radius: 3px;
  background: var(--chat-loading-main-color);
  animation: chatbot-voice-bar 0.85s ease-in-out infinite;
}
.chat-loading__chatbot-voice span:nth-child(1) {
  animation-delay: 0s;
}
.chat-loading__chatbot-voice span:nth-child(2) {
  animation-delay: 0.1s;
}
.chat-loading__chatbot-voice span:nth-child(3) {
  animation-delay: 0.2s;
}
.chat-loading__chatbot-voice span:nth-child(4) {
  animation-delay: 0.3s;
}
.chat-loading__chatbot-voice span:nth-child(5) {
  animation-delay: 0.4s;
}

.chat-loading__chatbot-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.chat-loading__chatbot-chip__pins {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 34px;
  gap: 5px;
}
.chat-loading__chatbot-chip__pins span {
  display: block;
  width: 5px;
  height: 7px;
  border-radius: 1px;
  background: var(--chat-loading-main-color-hover);
  opacity: 0.55;
  animation: chatbot-chip-pin 1.1s ease-in-out infinite;
}
.chat-loading__chatbot-chip__pins--left span:nth-child(2) {
  animation-delay: 0.15s;
}
.chat-loading__chatbot-chip__pins--left span:nth-child(3) {
  animation-delay: 0.3s;
}
.chat-loading__chatbot-chip__pins--right span:nth-child(1) {
  animation-delay: 0.22s;
}
.chat-loading__chatbot-chip__pins--right span:nth-child(2) {
  animation-delay: 0.37s;
}
.chat-loading__chatbot-chip__pins--right span:nth-child(3) {
  animation-delay: 0.52s;
}
.chat-loading__chatbot-chip__body {
  position: relative;
  width: 44px;
  height: 36px;
  box-sizing: border-box;
  border: 2px solid var(--chat-loading-main-color);
  border-radius: 6px;
  background: rgba(92, 103, 242, 0.07);
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-loading__chatbot-chip__core {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: linear-gradient(
    135deg,
    var(--sticky-theme-button-gradient-start, #8b9aff),
    var(--chat-loading-main-color)
  );
  animation: ai-thinking-pulse 1.15s ease-in-out infinite;
  box-shadow: 0 0 10px rgba(92, 103, 242, 0.4);
}

.chat-loading__chatbot-active {
  position: relative;
  width: 76px;
  height: 76px;
}
.chat-loading__chatbot-active__rings {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-loading__chatbot-active__rings span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 64px;
  height: 64px;
  margin: -32px 0 0 -32px;
  box-sizing: border-box;
  border: 2px solid var(--chat-loading-main-color);
  border-radius: 50%;
  animation: chatbot-active-ring 1.9s ease-out infinite;
  opacity: 0;
}
.chat-loading__chatbot-active__rings span:nth-child(2) {
  animation-delay: 0.35s;
}
.chat-loading__chatbot-active__rings span:nth-child(3) {
  animation-delay: 0.7s;
}
.chat-loading__chatbot-active__dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border-radius: 50%;
  z-index: 1;
  background: radial-gradient(
    circle at 32% 28%,
    rgba(255, 255, 255, 0.55),
    var(--chat-loading-main-color) 55%,
    var(--chat-loading-main-color-hover)
  );
  animation: ai-thinking-pulse 1.2s ease-in-out infinite;
  box-shadow:
    0 0 14px rgba(92, 103, 242, 0.5),
    inset 0 -4px 8px rgba(0, 0, 0, 0.12);
}
.chat-loading__chatbot-active__dot::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 6px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 10px 0 0 rgba(255, 255, 255, 0.92);
}
.chat-loading__chatbot-active__dot::after {
  content: "";
  position: absolute;
  bottom: 5px;
  left: 50%;
  width: 12px;
  height: 5px;
  margin-left: -6px;
  border-radius: 0 0 10px 10px;
  border: 2px solid transparent;
  border-bottom-color: rgba(255, 255, 255, 0.88);
  box-sizing: border-box;
}

/* --- 猫イメージスピナー（より可愛く・ぷっくり） --- */
.chat-loading__cat-face {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.chat-loading__cat-face__ears {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-bottom: -12px;
  z-index: 1;
}
.chat-loading__cat-face__ear {
  width: 0;
  height: 0;
  border-left: 13px solid transparent;
  border-right: 13px solid transparent;
  border-bottom: 22px solid var(--chat-loading-main-color);
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.1));
}
.chat-loading__cat-face__ear--l { transform: rotate(-15deg); }
.chat-loading__cat-face__ear--r { transform: rotate(15deg); }

.chat-loading__cat-face__head {
  position: relative;
  width: 66px;
  height: 58px;
  box-sizing: border-box;
  border: 3px solid var(--chat-loading-main-color);
  border-radius: 50% 50% 46% 46%; /* ぷっくりフォルム */
  background: linear-gradient(165deg, #fff 0%, #fff8f0 45%, color-mix(in srgb, var(--chat-loading-main-color), transparent 95%) 100%);
  box-shadow:
    inset 0 4px 10px rgba(255, 255, 255, 0.8),
    0 5px 15px rgba(15, 23, 42, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 14px;
}
.chat-loading__cat-face__eyes {
  display: flex;
  gap: 18px;
}
.chat-loading__cat-face__eye {
  position: relative;
  width: 15px;
  height: 15px; /* まんまるお目目 */
  border-radius: 50%;
  background: #2d2a28;
  animation: cat-face-blink 3.5s ease-in-out infinite;
}
.chat-loading__cat-face__eye::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fff; /* 瞳の輝き */
}
.chat-loading__cat-face__nose {
  width: 0;
  height: 0;
  margin-top: 3px;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 7px solid #ffb3c6; /* 優しいピンク */
  animation: cat-nose-twitch 2.4s ease-in-out infinite;
}
.chat-loading__cat-face__whiskers {
  position: absolute;
  bottom: 12px;
  left: 4px;
  right: 4px;
  display: flex;
  justify-content: space-between;
  opacity: 0.4;
}
.chat-loading__cat-face__whisker-side span {
  width: 18px;
  height: 1.5px;
  background: #4a4542;
}

.chat-loading__cat-nap {
  position: relative;
  width: 72px;
  height: 72px;
}
.chat-loading__cat-nap__ears {
  position: absolute;
  top: 6px;
  left: 50%;
  display: flex;
  gap: 32px;
  margin-left: -34px;
  z-index: 1;
}
.chat-loading__cat-nap__ears span {
  width: 0;
  height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-bottom: 14px solid var(--chat-loading-main-color);
}
.chat-loading__cat-nap__body {
  position: absolute;
  left: 50%;
  top: 18px;
  width: 66px;
  height: 46px;
  margin-left: -33px;
  box-sizing: border-box;
  border: 3px solid var(--chat-loading-main-color);
  border-radius: 50% 50% 44% 44%;
  background: linear-gradient(180deg, #fff 0%, #fff8f0 45%, color-mix(in srgb, var(--chat-loading-main-color), transparent 88%) 100%);
  box-shadow: inset 0 3px 8px rgba(255, 255, 255, 0.8);
}
.chat-loading__cat-nap__eyes {
  position: absolute;
  left: 50%;
  top: 12px;
  display: flex;
  gap: 12px;
  margin-left: -17px;
}
.chat-loading__cat-nap__eyes span {
  width: 11px;
  height: 3px;
  border-radius: 2px;
  background: rgba(45, 42, 40, 0.68);
}
.chat-loading__cat-nap__zzz {
  position: absolute;
  right: 2px;
  top: -4px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-family: "Arial Rounded MT Bold", "Segoe UI", sans-serif;
  font-weight: 900;
  color: var(--chat-loading-main-color);
  opacity: 0.85;
}
.chat-loading__cat-nap__zzz span {
  display: block;
  animation: cat-nap-z-float 2.5s ease-in-out infinite;
}
.chat-loading__cat-nap__zzz span:nth-child(1) { font-size: 0.7rem; animation-delay: 0s; }
.chat-loading__cat-nap__zzz span:nth-child(2) { font-size: 0.95rem; animation-delay: 0.3s; }
.chat-loading__cat-nap__zzz span:nth-child(3) { font-size: 1.2rem; animation-delay: 0.6s; }

@keyframes cat-face-blink {
  0%, 88%, 100% { transform: scaleY(1); }
  92%, 96% { transform: scaleY(0.1); }
}
@keyframes cat-nose-twitch {
  0%,
  100% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(1px);
  }
}
@keyframes cat-nap-z-float {
  0% {
    transform: translateY(6px);
    opacity: 0.3;
  }
  40% {
    opacity: 1;
  }
  100% {
    transform: translateY(-18px);
    opacity: 0;
  }
}

/* --- 頭脳・LLM 思考イメージ (🧠ベース & 神経パルス) --- */
.chat-loading__llm-brain {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 60px;
  /* 脳はデフォルトでピンク系 */
  --chat-loading-main-color: var(--chat-loading-character-color, #ffb3c6);
  --chat-loading-main-color-hover: color-mix(in srgb, var(--chat-loading-main-color), #000 15%);
}

.llm-brain__emoji-base {
  position: relative;
  width: 56px;
  height: 44px;
  background: var(--chat-loading-main-color);
  border: 2px solid var(--chat-loading-main-color-hover);
  border-radius: 40% 45% 45% 40% / 50% 50% 50% 50%;
  box-shadow: 
    inset -4px -4px 10px rgba(0, 0, 0, 0.05),
    inset 4px 4px 10px rgba(255, 255, 255, 0.7);
  animation: llm-brain-wobble 3s ease-in-out infinite;
}

/* 脳の「こぶ」を表現するローブ */
.llm-brain__lobe {
  position: absolute;
  background: inherit;
  border: 2px solid var(--chat-loading-main-color-hover);
  border-radius: 50%;
}

/* 🧠の形に近づけるための配置 */
.llm-brain__lobe--top-left { width: 32px; height: 32px; top: -14px; left: -4px; z-index: -1; }
.llm-brain__lobe--top-right { width: 36px; height: 36px; top: -16px; right: -6px; z-index: -1; }
.llm-brain__lobe--bottom-left { width: 28px; height: 28px; bottom: -8px; left: 2px; z-index: -1; }
.llm-brain__lobe--bottom-right { width: 32px; height: 32px; bottom: -10px; right: 0; z-index: -1; }

/* 内部の「脳のシワ」を box-shadow で表現 */
.llm-brain__emoji-base::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: inherit;
  box-shadow: 
    4px 8px 0 -4px rgba(255, 255, 255, 0.4),
    -4px 12px 0 -4px rgba(255, 255, 255, 0.3),
    8px -4px 0 -4px rgba(255, 255, 255, 0.3);
  opacity: 0.8;
}

/* 神経パルス (Neural Pulses) */
.llm-brain__pulses {
  position: absolute;
  inset: -10px;
  pointer-events: none;
}

.llm-brain__pulses span {
  position: absolute;
  width: 4px;
  height: 4px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 8px #fff, 0 0 12px var(--chat-loading-main-color);
  opacity: 0;
}

.llm-brain__pulses span:nth-child(1) { animation: llm-pulse-path-1 2.2s linear infinite; }
.llm-brain__pulses span:nth-child(2) { animation: llm-pulse-path-2 2.5s linear infinite 0.6s; }
.llm-brain__pulses span:nth-child(3) { animation: llm-pulse-path-3 2s linear infinite 1.2s; }
.llm-brain__pulses span:nth-child(4) { animation: llm-pulse-path-4 2.8s linear infinite 0.3s; }

@keyframes llm-brain-wobble {
  0%, 100% { transform: scale(1) translate(0, 0); }
  33% { transform: scale(1.02) translate(1px, -1px); }
  66% { transform: scale(0.98) translate(-1px, 1px); }
}

@keyframes llm-pulse-path-1 {
  0% { top: 20%; left: 20%; opacity: 0; transform: scale(0.5); }
  10% { opacity: 1; transform: scale(1.2); }
  40% { top: 40%; left: 70%; }
  60% { top: 80%; left: 50%; }
  90% { opacity: 1; transform: scale(1); }
  100% { top: 90%; left: 30%; opacity: 0; }
}

@keyframes llm-pulse-path-2 {
  0% { top: 70%; left: 80%; opacity: 0; transform: scale(0.5); }
  10% { opacity: 1; transform: scale(1.2); }
  50% { top: 30%; left: 40%; }
  90% { opacity: 1; transform: scale(1); }
  100% { top: 10%; left: 60%; opacity: 0; }
}

@keyframes llm-pulse-path-3 {
  0% { top: 40%; left: 10%; opacity: 0; transform: scale(0.5); }
  10% { opacity: 1; transform: scale(1.2); }
  50% { top: 60%; left: 90%; }
  90% { opacity: 1; transform: scale(1); }
  100% { top: 50%; left: 50%; opacity: 0; }
}

@keyframes llm-pulse-path-4 {
  0% { top: 10%; left: 50%; opacity: 0; transform: scale(0.5); }
  10% { opacity: 1; transform: scale(1.2); }
  50% { top: 90%; left: 50%; }
  90% { opacity: 1; transform: scale(1); }
  100% { top: 40%; left: 40%; opacity: 0; }
}

.chat-loading__llm-layers {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 54px;
}
.chat-loading__llm-layers span {
  height: 4px;
  border-radius: 2px;
  background: var(--chat-loading-main-color);
  max-width: 100%;
  animation: llm-layer-pulse 1.25s ease-in-out infinite;
}
.chat-loading__llm-layers span:nth-child(1) {
  width: 62%;
  animation-delay: 0s;
}
.chat-loading__llm-layers span:nth-child(2) {
  width: 78%;
  animation-delay: 0.1s;
}
.chat-loading__llm-layers span:nth-child(3) {
  width: 100%;
  animation-delay: 0.2s;
}
.chat-loading__llm-layers span:nth-child(4) {
  width: 78%;
  animation-delay: 0.3s;
}
.chat-loading__llm-layers span:nth-child(5) {
  width: 62%;
  animation-delay: 0.4s;
}

.chat-loading__llm-tokens {
  position: relative;
  width: 44px;
  height: 50px;
  overflow: hidden;
}
.chat-loading__llm-tokens span {
  position: absolute;
  bottom: -14px;
  width: 8px;
  height: 11px;
  border-radius: 2px;
  background: var(--chat-loading-main-color);
  box-shadow: 0 0 8px color-mix(in srgb, var(--chat-loading-main-color), transparent 65%);
  opacity: 0;
  animation: llm-token-rise 1.5s ease-in infinite;
}
.chat-loading__llm-tokens span:nth-child(1) {
  left: 4px;
  animation-delay: 0s;
}
.chat-loading__llm-tokens span:nth-child(2) {
  left: 14px;
  animation-delay: 0.22s;
}
.chat-loading__llm-tokens span:nth-child(3) {
  left: 24px;
  animation-delay: 0.44s;
}
.chat-loading__llm-tokens span:nth-child(4) {
  left: 34px;
  animation-delay: 0.66s;
}

.chat-loading__llm-mesh {
  display: grid;
  grid-template-columns: repeat(3, 10px);
  grid-template-rows: repeat(3, 10px);
  gap: 5px;
  justify-content: center;
  align-content: center;
}
.chat-loading__llm-mesh span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--chat-loading-main-color);
  justify-self: center;
  align-self: center;
  opacity: 0.28;
  animation: llm-mesh-cell 1.4s ease-in-out infinite;
}
.chat-loading__llm-mesh span:nth-child(1) {
  animation-delay: 0s;
}
.chat-loading__llm-mesh span:nth-child(2) {
  animation-delay: 0.08s;
}
.chat-loading__llm-mesh span:nth-child(3) {
  animation-delay: 0.16s;
}
.chat-loading__llm-mesh span:nth-child(4) {
  animation-delay: 0.24s;
}
.chat-loading__llm-mesh span:nth-child(5) {
  animation-delay: 0.32s;
}
.chat-loading__llm-mesh span:nth-child(6) {
  animation-delay: 0.4s;
}
.chat-loading__llm-mesh span:nth-child(7) {
  animation-delay: 0.48s;
}
.chat-loading__llm-mesh span:nth-child(8) {
  animation-delay: 0.56s;
}
.chat-loading__llm-mesh span:nth-child(9) {
  animation-delay: 0.64s;
}

.chat-loading__llm-nucleus {
  position: relative;
  width: 56px;
  height: 56px;
}
.chat-loading__llm-nucleus__orbit {
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 50%;
  border: 2px solid var(--chat-loading-main-color);
  box-sizing: border-box;
  opacity: 0.45;
  pointer-events: none;
}
.chat-loading__llm-nucleus__orbit--a {
  width: 48px;
  height: 48px;
  margin: -24px 0 0 -24px;
  transform: scaleY(0.42);
  animation: chat-loading-spin 3.1s linear infinite;
}
.chat-loading__llm-nucleus__orbit--b {
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px;
  transform: scaleY(0.48);
  border-color: var(--chat-loading-main-color-hover);
  opacity: 0.6;
  animation: chat-loading-spin-reverse 2.15s linear infinite;
}
.chat-loading__llm-nucleus__core {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  z-index: 2;
  background: radial-gradient(
    circle at 32% 32%,
    var(--sticky-theme-button-gradient-start, #8b9aff),
    var(--chat-loading-main-color) 60%,
    var(--chat-loading-main-color-hover)
  );
  animation: ai-thinking-pulse 1.15s ease-in-out infinite;
  box-shadow: 0 0 14px rgba(92, 103, 242, 0.5);
}

.chat-loading__label {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #1e293b;
}
.chat-loading__sub {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 500;
  color: #64748b;
  line-height: 1.45;
}

@keyframes ai-thinking-orbit {
  to {
    transform: rotate(360deg);
  }
}
@keyframes ai-thinking-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.12);
    opacity: 0.88;
  }
}
@keyframes chat-loading-spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes chat-loading-dot-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.85;
  }
  40% {
    transform: translateY(-12px);
    opacity: 1;
  }
}
@keyframes chat-loading-pulse-ring {
  0% {
    transform: scale(0.35);
    opacity: 0.55;
  }
  100% {
    transform: scale(1);
    opacity: 0;
  }
}
@keyframes chat-loading-bar {
  0%,
  100% {
    height: 8px;
    opacity: 0.65;
  }
  50% {
    height: 36px;
    opacity: 1;
  }
}
@keyframes chat-loading-neural-orbit {
  to {
    transform: rotate(360deg);
  }
}
@keyframes chat-loading-neural-glow {
  0%,
  100% {
    opacity: 0.5;
    box-shadow: 0 0 4px color-mix(in srgb, var(--chat-loading-main-color), transparent 65%);
  }
  50% {
    opacity: 1;
    box-shadow: 0 0 12px rgba(92, 103, 242, 0.65);
  }
}
@keyframes chat-loading-spin-reverse {
  to {
    transform: rotate(-360deg);
  }
}
@keyframes chat-loading-synapse-node {
  0%,
  100% {
    opacity: 0.3;
  }
  50% {
    opacity: 1;
  }
}
@keyframes chat-loading-synapse-beam {
  0% {
    left: -12px;
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  88% {
    opacity: 1;
  }
  100% {
    left: calc(100% - 28px);
    opacity: 0;
  }
}
@keyframes chat-loading-cortex-scan {
  0% {
    background-position: 120% 0;
  }
  100% {
    background-position: -120% 0;
  }
}

@keyframes robot-face-antenna-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.12);
    opacity: 0.85;
  }
}
@keyframes robot-face-eye {
  0%,
  88%,
  100% {
    transform: scaleY(1);
    opacity: 1;
  }
  92%,
  96% {
    transform: scaleY(0.15);
    opacity: 0.75;
  }
}
@keyframes robot-face-mouth {
  0%,
  100% {
    transform: scaleX(1);
    opacity: 0.8;
  }
  50% {
    transform: scaleX(1.2);
    opacity: 1;
  }
}
@keyframes robot-antenna-led {
  0%,
  100% {
    opacity: 0.28;
  }
  50% {
    opacity: 1;
  }
}
@keyframes robot-android-soft-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.86;
  }
}
@keyframes robot-android-eye-blink {
  0%,
  88%,
  100% {
    opacity: 1;
  }
  90%,
  94% {
    opacity: 0.12;
  }
}
@keyframes chatbot-bubble-soft-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.87;
  }
}

@keyframes bubblebot-blink {
  0%,
  86%,
  100% {
    transform: scaleY(1);
  }
  88%,
  93% {
    transform: scaleY(0.12);
  }
}

@keyframes chatbot-assistant-blink {
  0%,
  86%,
  100% {
    transform: scaleY(1);
    opacity: 1;
  }
  90%,
  94% {
    transform: scaleY(0.2);
    opacity: 0.7;
  }
}
@keyframes chatbot-voice-bar {
  0%,
  100% {
    height: 9px;
    opacity: 0.6;
  }
  50% {
    height: 34px;
    opacity: 1;
  }
}
@keyframes chatbot-chip-pin {
  0%,
  100% {
    opacity: 0.35;
    transform: scaleY(0.88);
  }
  50% {
    opacity: 1;
    transform: scaleY(1.12);
  }
}
@keyframes chatbot-active-ring {
  0% {
    transform: scale(0.32);
    opacity: 0.55;
  }
  100% {
    transform: scale(1);
    opacity: 0;
  }
}

@keyframes llm-layer-pulse {
  0%,
  100% {
    opacity: 0.32;
    transform: scaleX(0.94);
  }
  50% {
    opacity: 1;
    transform: scaleX(1);
  }
}
@keyframes llm-token-rise {
  0% {
    transform: translateY(0);
    opacity: 0;
  }
  14% {
    opacity: 1;
  }
  85% {
    opacity: 0.9;
  }
  100% {
    transform: translateY(-58px);
    opacity: 0;
  }
}
@keyframes llm-mesh-cell {
  0%,
  100% {
    opacity: 0.2;
    transform: scale(0.9);
  }
  50% {
    opacity: 1;
    transform: scale(1.12);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ai-thinking__ring {
    animation-duration: 6s;
  }
  .ai-thinking__core {
    animation: none;
  }
  .spinner-classic,
  .spinner-minimal {
    animation-duration: 1.6s;
  }
  .chat-loading__dots span {
    animation-duration: 1.8s;
  }
  .chat-loading__pulse-ring {
    animation-duration: 3.5s;
  }
  .chat-loading__bars span {
    animation-duration: 1.6s;
  }
  .chat-loading__neural-orbit {
    animation-duration: 8s;
  }
  .chat-loading__neural-orbit span {
    animation-duration: 2s;
  }
  .chat-loading__dual-ring-outer {
    animation-duration: 3.5s;
  }
  .chat-loading__dual-ring-inner {
    animation-duration: 2.8s;
  }
  .chat-loading__spark-orbit {
    animation-duration: 7s;
  }
  .chat-loading__synapse > span,
  .chat-loading__synapse-beam {
    animation-duration: 2.2s;
  }
  .chat-loading__cortex-line {
    animation-duration: 3.2s;
  }
  .chat-loading__robot-face__antenna::after {
    animation-duration: 2.2s;
  }
  .chat-loading__robot-face__eye {
    animation-duration: 4s;
  }
  .chat-loading__robot-face__mouth {
    animation-duration: 2s;
  }
  .chat-loading__robot-gears__wheel--a {
    animation-duration: 3.2s;
  }
  .chat-loading__robot-gears__wheel--b {
    animation-duration: 2.6s;
  }
  .chat-loading__robot-antenna__ball,
  .chat-loading__robot-antenna__body span {
    animation-duration: 2s;
  }
  .chat-loading__robot-tread-svg {
    animation-duration: 2.4s;
  }
  .chat-loading__android-eye,
  .chat-loading__android-eye--r {
    animation-duration: 4.5s;
  }
  .chat-loading__chatbot-bubble-svg {
    animation-duration: 2.5s;
  }
  .chat-loading__bubblebot-eye,
  .chat-loading__bubblebot-eye--r {
    animation-duration: 5.5s;
  }
  .chat-loading__chatbot-assistant__ring {
    animation-duration: 6s;
  }
  .chat-loading__chatbot-assistant__eyes span {
    animation-duration: 4s;
  }
  .chat-loading__chatbot-voice span {
    animation-duration: 1.5s;
  }
  .chat-loading__chatbot-chip__pins span,
  .chat-loading__chatbot-chip__core {
    animation-duration: 2s;
  }
  .chat-loading__chatbot-active__rings span,
  .chat-loading__chatbot-active__dot {
    animation-duration: 2.8s;
  }
  .llm-brain__emoji-base,
  .llm-brain__pulses span {
    animation-duration: 4s;
  }
  .chat-loading__llm-layers span {
    animation-duration: 2s;
  }
  .chat-loading__llm-tokens span {
    animation-duration: 2.4s;
  }
  .chat-loading__llm-mesh span {
    animation-duration: 2.2s;
  }
  .chat-loading__llm-nucleus__orbit--a {
    animation-duration: 5.5s;
  }
  .chat-loading__llm-nucleus__orbit--b {
    animation-duration: 4s;
  }
  .chat-loading__llm-nucleus__core {
    animation-duration: 2.2s;
  }
  .chat-loading__cat-face__eye {
    animation-duration: 4.5s;
  }
  .chat-loading__cat-nap__zzz span {
    animation-duration: 3.2s;
  }
}

.input-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    box-sizing: border-box; /* ← 追加 */
    background-color: white;
    padding: 10px;
    z-index: 100;
    box-shadow: 0 -2px 6px rgba(0,0,0,0.1);
}
#message-content {
    margin-bottom: 80px;
}
/* スマホ相当: フォント変数を一段小さく（本文・吹き出し・ボタンは var 参照で追随）
   vw だと横持ちで幅が広く文字だけ大きくなる → 縦横で短辺に揃えるため vmin を使用
   入力欄は 16px 未満だと iOS Safari がフォーカス時にズームするため下限維持 */
@media screen and (max-width: 480px),
       screen and (max-width: 1024px) and (max-height: 500px),
       screen and (orientation: portrait) and (max-width: 1024px) {
  :root {
    --font-chat-bubble: clamp(10.5px, 2.1vmin + 3.5px, 13px);
    --font-chat-label: clamp(9.5px, 1vmin + 6px, 12px);
    --font-ui-button: clamp(11px, 1.8vmin + 4.5px, 13px);
    --font-body-ui: clamp(11.5px, 1.4vmin + 7px, 14px);
    --font-input-touch: max(16px, var(--font-body-ui));
  }

  body {
    font-size: var(--font-body-ui);
  }
  .chat-bubble,
  .user-bubble,
  .bot-bubble {
    font-size: var(--font-chat-bubble) !important;
  }
  input[type="text"],
  #user_input {
    font-size: var(--font-input-touch) !important;
  }
  button,
  .solution-button,
  .suggestion-button,
  .button-button {
    font-size: var(--font-ui-button) !important;
  }
  .chat-label {
    font-size: var(--font-chat-label) !important;
  }
  #foreignlanguage,
  select {
    font-size: var(--font-body-ui);
  }

  .solution-buttons-container {
    flex-direction: row !important; /* 横並びを強制 */
    justify-content: center !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    bottom: 100px;  
  }

  .solution-button {
    white-space: nowrap !important;
    flex: 0 1 auto !important;
    min-width: 120px !important;
    max-width: 150px !important;
  }
}

/* スマホ: mobile_show_*
   - 狭い幅
   - 横向きで幅>480（高さが低い）
   - 縦向きで幅が広い（Safari「PC版サイト」等で幅≈980 になり max-width:480 に入らない場合） */
@media screen and (max-width: 480px),
       screen and (max-width: 1024px) and (max-height: 500px),
       screen and (orientation: portrait) and (max-width: 1024px) {
  body[data-mobile-msg-line1="0"] #message-button .head-message-line--1,
  body[data-mobile-msg-line1="0"] #message-button .head-message-line-fallback {
    display: none !important;
  }
  body[data-mobile-msg-line2="0"] #message-button .head-message-line--2 {
    display: none !important;
  }
  body[data-mobile-msg-line3plus="0"] #message-button .head-message-line--3plus {
    display: none !important;
  }
  body[data-mobile-show-button="0"] #message-button .button-buttons {
    display: none !important;
  }
}

/* マスコットのみ (pointer: coarse) で実機タッチ主体に限定。PC レスポンシブは主に fine ポインタのため非表示にしない */
@media screen and (max-width: 480px) and (pointer: coarse),
       screen and (max-width: 1024px) and (max-height: 500px) and (pointer: coarse),
       screen and (orientation: portrait) and (max-width: 1024px) and (pointer: coarse) {
  body[data-mobile-show-mascot="0"] .header .header-mascot {
    display: none !important;
  }
}

/* スマホ相当：挨拶・質問付箋・回答付箋の横余白を最小化して表示域を最大化 */
@media screen and (max-width: 480px),
       screen and (max-width: 1024px) and (max-height: 500px),
       screen and (orientation: portrait) and (max-width: 1024px) {
  .chat-container {
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
    padding: 4px;
    box-sizing: border-box;
    border-radius: 0;
  }
  #message-content {
    padding: 4px;
    box-sizing: border-box;
  }
  #message-button {
    width: 100%;
    box-sizing: border-box;
  }
  #message-button > div {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  #message-button .message-content,
  #message-button .head-message-lines,
  #message-button .head-message-line-fallback,
  #message-button .head-message-line {
    width: 100%;
    max-width: 100% !important;
    box-sizing: border-box;
  }
  /* 履歴エリア：左右余白を最小化（回答付箋を横いっぱいに近づける） */
  #chat-history.chat-history {
    padding: 4px 4px 100px;
    margin: 2px 0 !important;
    margin-right: 0 !important;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    /* 末尾へスクロールしたとき固定UIと被りにくくする */
    scroll-padding-bottom: 16px;
  }
  /* 解決ボタン行表示時（body に .solution-buttons-on を付与）は下余白を追加（JS と併用） */
  body.solution-buttons-on #chat-history.chat-history {
    padding-bottom: 240px;
  }
  /* 質問付箋：短文では文字幅に収まる（全幅に伸ばさない）。長文は折り返し上限あり */
  .message-container--user,
  .message-container:has(.chat-user) {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    gap: 4px;
  }
  .message-container--user > .chat-message,
  .message-container:has(.chat-user) > .chat-message {
    flex: 0 1 auto;
    min-width: 0;
    max-width: calc(100% - 44px);
    text-align: right;
  }
  .message-container--user .user-icon,
  .message-container:has(.chat-user) .user-icon {
    margin-left: 2px;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
  }
  .message-container--user .user-bubble,
  .message-container:has(.chat-user) .user-bubble {
    display: inline-block;
    width: fit-content;
    max-width: 100% !important;
    box-sizing: border-box;
    vertical-align: top;
  }
  .chat-bot .message-container {
    width: 100%;
    max-width: 100%;
    align-items: stretch;
  }
  .chat-bot .bot-icon {
    margin-bottom: 4px;
  }
  .bot-bubble {
    display: block;
    max-width: 100% !important;
    width: 100%;
    box-sizing: border-box;
    float: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
  .chat-bot .chat-message {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
}
/* 汎用 */
.hidden { display: none !important; }

/* 画像・セレクタの見た目（もともと inline style だった内容） */
.theme-icon { height: 30px; margin-right: 10px; cursor: pointer; }
.theme-selector { margin-left: 10px; }

/* ローディング表示：.runtime の詳細は上段（オーバーレイ＋flex）を参照 */

/* ヘッダー左右の整列 */
.header-controls { display:flex; align-items:center; gap:10px; }

/* フローティング等 iframe 埋め込み時: 親ページの × ボタンと重ならない余白 */
body.embedded-chat .header-controls {
  margin-right: 52px;
}

/* モーダル（inline → クラス） */
.modal {
  position: fixed; top:50%; left:50%;
  transform: translate(-50%, -50%);
  background:#fff; border:1px solid #ccc; padding:20px;
  z-index:9999; box-shadow:0 0 10px rgba(0,0,0,0.3);
  text-align:center; border-radius:10px;
}
.modal-image { max-width:100px; height:auto; margin-bottom:10px; }
.modal-ok { margin-top:8px; }
.modal-comment-wrap { margin: 12px 0; text-align: left; max-width: 360px; margin-left: auto; margin-right: auto; }
.modal-comment-label { display: block; font-size: 14px; margin-bottom: 6px; color: #333; }
.modal-comment-input { width: 100%; box-sizing: border-box; padding: 8px; border: 1px solid #ccc; border-radius: 6px; font-family: inherit; font-size: 14px; resize: vertical; min-height: 72px; }
.modal-guide-wrap { margin: 12px 0; }
.modal-guide-link { display: inline-block; word-break: break-all; color: var(--sticky-theme-primary, var(--primary-color, #1565c0)); text-decoration: underline; font-size: 15px; }
.modal-guide-link:hover { opacity: 0.85; }

/* ボタン文字色の初期値（白） */
:root { --button-text-color: #ffffff; }

/* === CSP対応のユーティリティ === */
.hidden { display: none !important; }
.inline-block { display: inline-block !important; }
.flex { display: flex !important; }
.mt-5 { margin-top: 5px !important; }
.text-black { color: #000 !important; }
/* テーマのアクセント色（DB色を使わない方針に切替） */
.text-accent { color: var(--sticky-theme-primary, var(--primary-color)) !important; }

/* 解決ボタン：表示制御用（JSが .flex/.hidden を付け替える） */
#solution-buttons-global.flex { display: flex; }
#solution-buttons-global.hidden { display: none; }

/* DSP_CHAT sticky_solution_button_style（body data-* → JS が CSS 変数を #solution-buttons-global に設定し .sticky-solution-custom を付与） */
#solution-buttons-global.sticky-solution-custom .solution-button {
  background: var(
    --sticky-solution-button-bg,
    linear-gradient(
      145deg,
      var(--sticky-theme-button-gradient-start, var(--button-gradient-start)),
      var(--sticky-theme-button-gradient-end, var(--button-gradient-end))
    )
  ) !important;
  color: var(--sticky-solution-button-text, var(--sticky-theme-button-text-color, var(--button-text-color))) !important;
}
#solution-buttons-global.sticky-solution-custom .solution-button:hover {
  background: var(
    --sticky-solution-button-hover-bg,
    var(
      --sticky-solution-button-bg,
      linear-gradient(
        145deg,
        var(--sticky-theme-button-gradient-end, var(--button-gradient-end)),
        var(--sticky-theme-user-bubble-border, var(--user-bubble-border))
      )
    )
  ) !important;
}

/* モーダルの表示/非表示（JSは hidden クラスだけ触る） */
.modal.hidden { visibility: hidden; opacity: 0; }
.modal { visibility: visible; opacity: 1; transition: opacity .2s ease; }

/* ===========================================
   chat.css - CSP対応修正版（2025-10-17）
   =========================================== */

/* 基本リセット */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Helvetica Neue", Arial, sans-serif;
  background-color: #f5f7fa;
  color: #333;
  font-size: var(--font-body-ui);
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* チャット画面 */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* メッセージリスト */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background-color: #e9eef5;
}

/* メッセージ共通 */
.message {
  display: flex;
  align-items: flex-end;
  margin-bottom: 12px;
}

/* 吹き出し */
.message-content {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 12px;
  line-height: 1.4;
  word-break: break-word;
}

/* ユーザー側 */
.message.user .message-content {
  background-color: #daf1ff;
  color: #000;
  border-bottom-right-radius: 0;
  margin-left: auto;
}

/* ボット側 */
.message.bot .message-content {
  background-color: #fff;
  border-bottom-left-radius: 0;
}

/* スクロールバー */
.chat-messages::-webkit-scrollbar {
  width: 8px;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

/* 入力エリア */
.chat-input {
  display: flex;
  padding: 12px;
  background: #fff;
  border-top: 1px solid #ccc;
}

.chat-input textarea {
  flex: 1;
  resize: none;
  height: 48px;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 8px;
}

.chat-input button {
  margin-left: 8px;
  padding: 0 16px;
  background: var(--sticky-theme-primary, var(--primary-color, #007bff));
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.chat-input button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ============================
   新規追加クラス (CSP対応)
   ============================ */

/* margin-top:5px; の代替 */
.mt-5 {
  margin-top: 5px;
}

/* color:black の代替 */
.text-black {
  color: #000;
}

/* 注意・強調テキスト */
.text-accent {
  color: var(--sticky-theme-primary, var(--primary-color, #007bff));
  font-weight: 600;
}

/* 注意メッセージバリエーション */
.precautions {
  font-weight: 600;
}
.precautions--red {
  color: #d00;
}
.precautions--green {
  color: #080;
}
.precautions--blue {
  color: #06c;
}

/* システムメッセージなど */
.system-message {
  text-align: center;
  color: #555;
  font-size: 0.9em;
  margin: 10px 0;
}

/* 添付ファイル */
/* 添付ファイル名を入力欄の1行上に固定表示する */
#attachPreview {
  position: fixed;
  left: 0;
  bottom: 60px;              /* 入力エリアのちょうど1行上くらい */
  width: 100%;
  box-sizing: border-box;

  padding: 4px 60px 4px 44px; /* 左: ＋ボタンぶん / 右: 送信ボタンぶんの余白 */
  background-color: #fff;
  border-top: 1px solid #eee;
  font-size: 0.9rem;
  color: #333;
  z-index: 101;              /* 入力欄より前面に出す */
}
/* 添付ファイル名のチップ表示 */
.attach-chip {
  display: inline-block;
  margin: 2px 4px 2px 0;
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid #ccc;
  background: #f5f5f5;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  color: #000;
}

.attach-chip:hover {
  background: #e8e8e8;
}
.attach-list .attach-button { display:inline-block; margin:.25rem .25rem 0 0; padding:.25rem .5rem; border:1px solid #ccc; border-radius:.5rem; text-decoration:none; }

/* 添付バー（ChatGPT風） */
.attach-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 4px;
}

/* ＋ボタンを小さく丸く */
.attach-button {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

#attachInput {
  display: none;
}
/* ===== 添付ファイル名を横書きにする調整 ===== */
.chat-bubble .attach-list {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* ===== 吹き出し内の添付ファイル表示（質問者・オペレータ共通） ===== */
.chat-bubble .attach-list {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  writing-mode: horizontal-tb !important; /* 親ごと横書きに固定 */
}

/* ============================
   クールな添付ファイルチップデザイン
   ============================ */

.chat-bubble .attach-list .attach-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;

  padding: 6px 14px 6px 32px;
  border-radius: 14px;

  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);            /* ★ ガラス効果 */
  border: 1px solid rgba(255, 255, 255, 0.25);

  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);

  font-size: 0.9rem;
  font-weight: 500;
  color: #0f172a;
  text-decoration: none;

  white-space: normal;
  word-break: break-all;
  max-width: 1260px;

  transition: all 0.25s ease;
}

/* 左にアイコン（📎 → クールなアイコンに変更） */
.chat-bubble .attach-list .attach-button::before {
  content: "🗂️";                        /* ← 変更可能：📎📄📁 など */
  position: absolute;
  left: 10px;
  font-size: 1rem;
  opacity: 0.9;
}

/* ホバー時の光るエフェクト */
.chat-bubble .attach-list .attach-button:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(80, 140, 255, 0.8);

  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 6px 16px rgba(60, 130, 255, 0.35);
}

/* クリック時のフィードバック */
.chat-bubble .attach-list .attach-button:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}
/* 吹き出し内の添付ファイルボタン（固定幅200px） */
.chat-bubble .attach-list .attach-button-wide {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;

  padding: 6px 14px 6px 32px;
  border-radius: 14px;

  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.25);

  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);

  font-size: 0.9rem;
  font-weight: 500;
  color: #0f172a;
  text-decoration: none;

  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;

  /* width: 200px; ← これを削除 */
  /* 1文字幅を基準にした最大幅。ここでは 24 文字ぶん */
  max-width: 24ch;
  transition: all 0.25s ease;
}

/* アイコン */
.chat-bubble .attach-list .attach-button-wide::before {
  content: "🗂️";
  position: absolute;
  left: 10px;
  font-size: 1rem;
  opacity: 0.9;
}

/* ホバー */
.chat-bubble .attach-list .attach-button-wide:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(80, 140, 255, 0.8);
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 6px 16px rgba(60, 130, 255, 0.35);
}

/* クリック時 */
.chat-bubble .attach-list .attach-button-wide:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}
/* 質問欄（textarea版）の見た目 */
#user_input {
  flex: 1;               /* 余った横幅を全部使う */
  padding: 10px 12px;
  font-size: var(--font-input-touch);
  border: 1px solid #ccc;
  border-radius: 5px;
  box-sizing: border-box;
  min-width: 0;

  /* 縦方向に広げられるようにする */
  min-height: 48px;      /* 2行分くらい */
  max-height: 160px;     /* 上限（お好みで） */
  resize: vertical;      /* ユーザーがドラッグで高さ変更可 */
}

/* スマホ時は幅100%に */
@media screen and (max-width: 480px) {
  #user_input {
    width: 100%;
    font-size: var(--font-input-touch) !important;
  }
}
.chat-bubble table {
    border-collapse: collapse;
    width: 100%;
    max-width: 100%;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.chat-bubble th,
.chat-bubble td {
    border: 1px solid #ccc;
    padding: 4px 6px;
}

.chat-bubble th {
    background-color: #f3f4f6;
    font-weight: bold;
}
/* =========================================================
   追記CSS（最小差分）：入力欄＋送信ボタンの上下切替に伴う崩れ防止
   - JS が body に .input-position-top / .input-position-bottom を付与
   - wrapper div がレイアウトを壊さないよう display: contents
   ========================================================= */

#input-mount-top,
#input-mount-bottom {
  display: contents;
}

/* 上側表示時：固定を解除して通常フローへ（最重要）
   ※ chat.css 側で .input-controls が position: fixed; bottom:0; の場合に効く */
body.input-position-top .input-controls {
  position: static !important;
  inset: auto !important;
  bottom: auto !important;
  left: auto !important;
  right: auto !important;
  top: auto !important;
  width: 100% !important;
}

/* 上側表示時：下部固定用の余白があれば打ち消す（必要な場合のみ効く保険） */
body.input-position-top #message-content {
  padding-bottom: 0 !important;
}
