/* Chat widget on AI business card page - mobile-first */
.chat-widget-root {
    --chat-widget-root-bottom: 1.25rem;
    --chat-widget-toggle-height: 58px;
    --chat-widget-panel-gap: 0.5rem;
    --chat-widget-panel-margin: 1.25rem;
    position: fixed;
    bottom: var(--chat-widget-root-bottom) !important;
    right: 1.25rem;
    z-index: 9999;
    font-family: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Meiryo', sans-serif;
    transition: bottom 0.2s ease;
}

.chat-widget-root.is-install-banner-visible {
    --chat-widget-root-bottom: 11.25rem;
}

.chat-widget-root.is-pwa-modal-visible {
    --chat-widget-root-bottom: var(--chat-widget-pwa-bottom, 24rem);
    z-index: 10002;
}

.chat-widget-toggle {
    min-width: 260px;
    max-width: min(92vw, 360px);
    height: 58px;
    border-radius: 999px;
    background: #0b4f9f;
    color: #fff;
    border: none;
    box-shadow: 0 4px 16px rgba(11, 79, 159, 0.32);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.6rem;
    padding: 0.35rem 1.1rem 0.35rem 0.4rem;
    font-size: 1rem;
    transition: transform 0.2s, box-shadow 0.2s;
}
.chat-widget-toggle-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    object-fit: cover;
    flex: 0 0 46px;
    border: 2px solid rgba(255, 255, 255, 0.7);
    background: #fff;
}
.chat-widget-toggle-avatar-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #0b4f9f;
    font-weight: 700;
}
/* 「●●様専用 / AI住まいコンシェルジュ」の2段組み（改善要望 1-9）。
   文字サイズ切替（標準／大／特大）で大きくなると58pxの高さに収まらなくなるため、
   ここだけは px 固定にして、どの設定でもボタンの形が崩れないようにする。 */
.chat-widget-toggle-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-width: 0;
    gap: 1px;
    text-align: left;
}
.chat-widget-toggle-owner {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    opacity: 0.92;
}
.chat-widget-toggle-label {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 700;
    font-size: 19px;
    line-height: 1.2;
    letter-spacing: 0;
}
.chat-widget-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 102, 204, 0.5);
}
.chat-widget-toggle:active {
    transform: scale(0.98);
}

.chat-widget-panel {
    position: absolute;
    bottom: calc(var(--chat-widget-toggle-height) + var(--chat-widget-panel-gap));
    right: 0;
    display: flex;
    flex-direction: column;
    width: min(94vw, 680px);
    height: min(860px, calc(100vh - var(--chat-widget-root-bottom) - var(--chat-widget-toggle-height) - var(--chat-widget-panel-gap) - var(--chat-widget-panel-margin)));
    max-height: calc(100vh - var(--chat-widget-root-bottom) - var(--chat-widget-toggle-height) - var(--chat-widget-panel-gap) - var(--chat-widget-panel-margin));
    height: min(860px, calc(100dvh - var(--chat-widget-root-bottom) - var(--chat-widget-toggle-height) - var(--chat-widget-panel-gap) - var(--chat-widget-panel-margin)));
    max-height: calc(100dvh - var(--chat-widget-root-bottom) - var(--chat-widget-toggle-height) - var(--chat-widget-panel-gap) - var(--chat-widget-panel-margin));
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.chat-widget-panel[hidden] {
    display: none !important;
}

.chat-widget-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: #0066cc;
    color: #fff;
    /* 上部の青いバーは常に固定し、縦が足りなくても縮めない */
    flex-shrink: 0;
}
.chat-widget-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: #fff;
}
.chat-widget-header-text {
    flex: 1;
    min-width: 0;
}
.chat-widget-header-actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}
.chat-widget-icon-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    cursor: pointer;
    border-radius: 50%;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.18s ease, transform 0.18s ease;
}
/* display:inline-flex が UA の [hidden]{display:none} に勝ってしまうため、明示的に隠す。 */
.chat-widget-icon-btn[hidden] {
    display: none;
}
.chat-widget-icon-btn:hover {
    background: rgba(255, 255, 255, 0.28);
    transform: translateY(-1px);
}
.chat-widget-icon-btn svg {
    width: 18px;
    height: 18px;
    display: block;
    fill: currentColor;
}
.chat-widget-icon-btn[hidden] {
    display: none;
}
.chat-widget-agent-name {
    display: block;
    font-weight: 600;
    font-size: 0.95rem;
}
.chat-widget-badge {
    font-size: 0.75rem;
    opacity: 0.9;
}
.chat-widget-close {
    font-size: 1.45rem;
    line-height: 1;
}

.chat-widget-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1rem;
    /* 0 にして、画面が狭いときはメッセージ欄が縮むようにする。
       260px 固定だと縦が足りない端末でフレックス列が溢れ、
       最下部のタブ（AI担当〜担当連絡）が画面外に押し出されていた。 */
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-msg {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    max-width: 96%;
}
.chat-msg-content {
    min-width: 0;
}
.chat-msg.user {
    flex-direction: row-reverse;
    align-self: flex-end;
}
.chat-msg .chat-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.chat-msg.user .chat-msg-avatar {
    display: none;
}
.chat-msg-bubble {
    padding: 0.6rem 0.9rem;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
}
.chat-msg.bot .chat-msg-bubble {
    background: #e8f0fe;
    color: #1a1a1a;
    border-bottom-left-radius: 4px;
}
.chat-bubble-candidates {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
    margin-top: 0.75rem;
    white-space: normal;
}
.chat-bubble-candidate-btn {
    width: 100%;
    text-align: left;
    border-radius: 8px;
    line-height: 1.4;
}
.chat-bubble-candidate-btn:disabled {
    cursor: default;
    opacity: 0.6;
}
.chat-msg.bot.is-typing .chat-msg-bubble::after {
    content: '';
    display: inline-block;
    width: 0.45em;
    height: 1em;
    margin-left: 2px;
    vertical-align: -0.14em;
    border-right: 2px solid rgba(26, 26, 26, 0.72);
    animation: chat-type-caret 0.85s steps(1, end) infinite;
}
@keyframes chat-type-caret {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
    .chat-msg.bot.is-typing .chat-msg-bubble::after {
        animation: none;
    }
}
.chat-msg.user .chat-msg-bubble {
    background: #0066cc;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-msg-time {
    font-size: 0.7rem;
    color: #888;
    margin-top: 0.2rem;
}
.chat-msg.user .chat-msg-time {
    text-align: right;
}

.chat-widget-voice-notice {
    align-self: stretch;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid #f4d58a;
    border-radius: 8px;
    background: #fff8e6;
    color: #8a5a00;
    font-size: 0.82rem;
    line-height: 1.45;
    margin-inline: 2rem;
}
.chat-widget-voice-notice-icon {
    display: inline-flex;
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    align-items: center;
    justify-content: center;
    color: #0b4f9f;
}
.chat-widget-voice-notice-icon svg {
    width: 18px;
    height: 18px;
    display: block;
    fill: currentColor;
}

.chat-msg-sources {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-top: 0.45rem;
    font-size: 0.75rem;
    line-height: 1.35;
    display: none;
}
.chat-msg-sources span {
    color: #667085;
    font-weight: 600;
}
.chat-msg-sources a {
    color: #0052a3;
    text-decoration: underline;
    overflow-wrap: anywhere;
}
.chat-msg-sources .chat-msg-source-meta {
    color: #98a2b3;
    font-weight: 400;
}

/* Red pin that links to Google Maps. Only the pin is clickable; the address
   text that follows it stays plain (no link, no underline). */
.chat-msg-address-pin {
    text-decoration: none;
    margin-right: 2px;
    cursor: pointer;
    line-height: 1;
}
.chat-msg-address-pin:hover {
    opacity: 0.8;
}

.chat-widget-quick-actions {
    flex: 0 0 auto;
    max-height: 116px;
    overflow-y: auto;
    padding: 0.5rem 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    border-top: 1px solid #eef2f7;
}
.chat-widget-quick-actions.is-hidden-until-bottom {
    display: none !important;
}
.chat-widget-feature-panel {
    flex: 0 0 auto;
    max-height: 220px;
    overflow: auto;
    padding: 0.6rem 1rem 0.3rem;
    border-top: 1px solid #e7edf8;
    background: #f8fbff;
}
.chat-widget-panel.is-feature-view .chat-widget-messages,
.chat-widget-panel.is-feature-view .chat-ai-head,
.chat-widget-panel.is-feature-view .chat-widget-quick-actions,
.chat-widget-panel.is-feature-view .chat-widget-geo-actions,
.chat-widget-panel.is-feature-view .chat-widget-input-wrap,
.chat-widget-panel.is-feature-view .chat-widget-voice-status {
    display: none !important;
}
/* 上の非表示ルールはAI担当のメイン入力欄（feature-panelの外側）を隠すためのもの。
   担当連絡の入力欄はAI担当と同じ .chat-widget-input* クラスを使い、かつ feature-panel
   の「内側」にあるため、このルールに巻き込まれて消えてしまう。feature-panel 内の
   入力欄・音声ステータスは明示的に表示し直す。 */
.chat-widget-panel.is-feature-view .chat-widget-feature-panel .chat-widget-input-wrap {
    display: grid !important;
}
.chat-widget-panel.is-feature-view .chat-widget-feature-panel .chat-widget-voice-status:not([hidden]) {
    display: block !important;
}
.chat-widget-panel.is-feature-view .chat-widget-feature-panel {
    flex: 1 1 auto;
    max-height: none;
    min-height: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    border-top: none;
}
.chat-feature-toolbar {
    flex: 0 0 auto;
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid #d9e4f2;
    background: #fff;
}
.chat-feature-back,
.chat-feature-geo {
    border: none;
    border-radius: 8px;
    background: #0b4f9f;
    color: #fff;
    padding: 0.52rem 0.75rem;
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
}
/* AI担当の上部ボタン（現在地情報をマップ表示 / 現在地情報を取得する）。
   機能タブでは上のルールで非表示にし、AI担当のときだけ出す。 */
.chat-widget-geo-actions {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid #d9e4f2;
    background: #fff;
}
.chat-widget-geo-btn {
    flex: 1 1 auto;
    border: none;
    border-radius: 8px;
    background: #0b4f9f;
    color: #fff;
    padding: 0.52rem 0.6rem;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.3;
    cursor: pointer;
}
.chat-widget-geo-btn:hover {
    background: #0a4589;
}
.chat-feature-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 0.75rem 1rem;
}
/* 担当連絡（人間担当↔顧客）チャット */
.chat-contact-view {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.chat-contact-head {
    flex: 0 0 auto;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid #eef2f7;
    background: #fff;
}
.chat-contact-head strong {
    display: block;
    font-size: 0.9rem;
    color: #0b4f9f;
}
.chat-contact-head span {
    font-size: 0.74rem;
    color: #6b7686;
}
.chat-contact-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: #f3f7fc;
}
.chat-contact-empty {
    margin: auto 0;
    color: #5f6b7a;
    font-size: 0.8rem;
    line-height: 1.5;
    text-align: center;
}
.chat-contact-attach-list {
    flex: 0 0 auto;
    padding: 0 1rem;
}
.chat-contact-attach-list:empty {
    padding: 0;
}
.chat-contact-input-wrap {
    flex: 0 0 auto;
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    padding: 0.6rem 1rem 0.8rem;
    border-top: 1px solid #e7edf8;
    background: #f8fbff;
}
.chat-contact-input {
    flex: 1 1 auto;
    resize: none;
    border: 1px solid #cdd8e6;
    border-radius: 10px;
    padding: 0.55rem 0.7rem;
    font-size: 0.85rem;
    font-family: inherit;
    line-height: 1.4;
}
.chat-contact-input-actions {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    flex-direction: column;
}
.chat-widget-default-prompt {
    flex-basis: 100%;
    color: #5f6b7a;
    font-size: 0.78rem;
    line-height: 1.45;
}
.chat-quick-btn {
    font-size: 0.8rem;
    padding: 0.4rem 0.75rem;
    border: 1px solid #0066cc;
    background: #fff;
    color: #0066cc;
    border-radius: 20px;
    cursor: pointer;
}
.chat-widget-input-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 66px;
    flex: 0 0 66px;
}
.chat-intake-replies {
    flex-basis: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-bottom: 0.25rem;
}
.chat-intake-reply {
    border-color: #1d7dd8;
    background: #eef6ff;
    color: #0b5394;
}
.chat-intake-reply:hover {
    background: #dceeff;
}

.chat-widget-entry-actions {
    flex-basis: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-bottom: 0.25rem;
}
.chat-entry-btn {
    background: #fff;
    border-color: #0b4f9f;
    color: #0b4f9f;
    font-weight: 700;
}
.chat-entry-btn:hover {
    background: #eef6ff;
}
.chat-sms-auth-box {
    align-self: stretch;
    margin: 0 0 0.25rem 2.5rem;
    padding: 0.85rem;
    border: 1px solid #d9e4f2;
    border-radius: 10px;
    background: #f8fbff;
    display: grid;
    gap: 0.45rem;
    max-width: 460px;
}
.chat-sms-auth-box label {
    color: #344054;
    font-size: 0.78rem;
    font-weight: 700;
}
.chat-sms-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.45rem;
}
.chat-sms-phone,
.chat-sms-code {
    min-width: 0;
    padding: 0.58rem 0.65rem;
    border: 1px solid #cfd8e3;
    border-radius: 8px;
    font: inherit;
    font-size: 0.9rem;
}
.chat-sms-send,
.chat-sms-verify {
    border: 1px solid #0066cc;
    border-radius: 8px;
    background: #0066cc;
    color: #fff;
    font-weight: 700;
    padding: 0.5rem 0.7rem;
    cursor: pointer;
}
.chat-sms-send:disabled,
.chat-sms-verify:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}
.chat-sms-status {
    min-height: 1.2em;
    color: #475467;
    font-size: 0.78rem;
    line-height: 1.45;
}
#chat-firebase-recaptcha {
    min-height: 1px;
}

.chat-profile-form {
    align-self: stretch;
    margin: 0 0 0.25rem 2.5rem;
    padding: 0.85rem;
    border: 1px solid #d9e4f2;
    border-radius: 10px;
    background: #f8fbff;
    display: grid;
    gap: 0.5rem;
    max-width: 460px;
}
.chat-profile-form label {
    color: #344054;
    font-size: 0.78rem;
    font-weight: 700;
}
.chat-profile-input {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 0.58rem 0.65rem;
    border: 1px solid #cfd8e3;
    border-radius: 8px;
    font: inherit;
    font-size: 0.9rem;
}
.chat-email-domains {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.chat-email-domain-btn {
    border: 1px solid #cfd8e3;
    border-radius: 999px;
    background: #fff;
    color: #0066cc;
    font: inherit;
    font-size: 0.8rem;
    padding: 0.32rem 0.6rem;
    cursor: pointer;
}
.chat-email-domain-btn:hover {
    background: #eef6ff;
}
.chat-profile-status {
    min-height: 1.2em;
    color: #475467;
    font-size: 0.78rem;
    line-height: 1.45;
}
.chat-profile-submit {
    justify-self: stretch;
    border: 1px solid #0066cc;
    border-radius: 8px;
    background: #0066cc;
    color: #fff;
    font-weight: 700;
    padding: 0.6rem 0.7rem;
    cursor: pointer;
}
.chat-profile-submit:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.chat-intake-multi-hint {
    flex-basis: 100%;
    font-size: 0.75rem;
    color: #475467;
    line-height: 1.4;
}
.chat-intake-reply.is-selected {
    background: #0066cc;
    border-color: #0066cc;
    color: #fff;
}
.chat-intake-submit {
    background: #12b76a;
    border-color: #12b76a;
    color: #fff;
    font-weight: 700;
}
.chat-intake-submit:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.chat-quick-btn:hover {
    background: #e8f0fe;
}

.chat-quick-btn.is-selected:hover {
    background: #003e7d;
}

.chat-feature-head,
.chat-feature-summary {
    display: flex;
    justify-content: space-between;
    gap: 0.6rem;
    align-items: center;
    margin-bottom: 0.7rem;
}
.chat-feature-head strong,
.chat-feature-summary strong {
    font-size: 0.9rem;
    color: #0b4f9f;
}
.chat-feature-head-text {
    min-width: 0;
}
/* 見出しの下に説明文を1行添える（担当連絡の見出しと同じ並び） */
.chat-feature-head-text strong,
.chat-feature-head-text h4 {
    display: block;
}
.chat-feature-head-text span {
    display: block;
    margin-top: 0.1rem;
}
.prop-toolbar__title {
    flex: 1 1 auto;
}
.prop-toolbar__title span {
    font-size: 0.78rem;
    color: #5f6b7a;
    line-height: 1.5;
}
.chat-feature-head span,
.chat-feature-summary p,
.chat-feature-small {
    font-size: 0.78rem;
    color: #5f6b7a;
    line-height: 1.5;
}
.chat-feature-field,
.chat-feature-grid label,
.chat-feature-card,
.chat-feature-list-row,
.chat-feature-tool {
    display: block;
    font-size: 0.8rem;
}
.chat-feature-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
    margin-bottom: 0.7rem;
}
.chat-feature-grid section,
.chat-feature-card,
.chat-feature-list-row {
    border: 1px solid #dbe5f2;
    border-radius: 8px;
    background: #fff;
    padding: 0.55rem;
}
.chat-feature-grid h4 {
    margin: 0 0 0.35rem;
    font-size: 0.82rem;
    color: #1d2b3a;
}

.chat-feature-field select {
    border: 1px solid #cdd8e6;
    border-radius: 4px;
    padding: 0.08rem 0.3rem;
    box-sizing: border-box;
    font: inherit;
    background: #fff;
}

.chat-feature-field input,
.chat-feature-field textarea,
.chat-feature-grid input,
.chat-feature-grid textarea,
.chat-feature-grid select {
    width: 100%;
    margin-top: 0.25rem;
    border: 1px solid #cdd8e6;
    border-radius: 8px;
    padding: 0.48rem 0.6rem;
    box-sizing: border-box;
    font: inherit;
    background: #fff;
}
.chat-feature-field textarea,
.chat-feature-grid textarea {
    min-height: 68px;
    resize: vertical;
}
/* iPhone の日付・日時入力は標準の見た目だと横幅をはみ出すため、他の入力欄と同じ幅に収める。 */
.chat-feature-field input[type="date"],
.chat-feature-field input[type="datetime-local"],
.chat-feature-grid input[type="date"],
.chat-feature-grid input[type="datetime-local"] {
    -webkit-appearance: none;
    appearance: none;
    display: block;
    min-width: 0;
    max-width: 100%;
    min-height: 2.4em;
    text-align: left;
}
.chat-feature-field input[type="date"]::-webkit-date-and-time-value,
.chat-feature-grid input[type="date"]::-webkit-date-and-time-value,
.chat-feature-grid input[type="datetime-local"]::-webkit-date-and-time-value {
    text-align: left;
}
.chat-feature-grid label {
    min-width: 0;
}
.chat-feature-error {
    margin: 0 0 0.6rem;
    font-size: 0.78rem;
    color: #c62828;
}
.chat-schedule-confirm {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.35rem 0.8rem;
    margin: 0 0 0.8rem;
    font-size: 0.9rem;
}
.chat-schedule-confirm dt {
    color: #5f6b7a;
}
.chat-schedule-confirm dd {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}
.chat-schedule-confirm-question {
    margin: 0 0 0.6rem;
    font-weight: 600;
}
/* 相談種別で1セクションのみ表示（購入/売却/賃貸単独）のときは全幅にする。 */
.chat-feature-grid section:only-child {
    grid-column: 1 / -1;
}
.chat-feature-checkgroup {
    margin-top: 0.45rem;
}
.chat-feature-checklabel {
    display: block;
    font-size: 0.8rem;
    color: #1d2b3a;
    margin-bottom: 0.3rem;
}
.chat-feature-checksub {
    font-size: 0.72rem;
    color: #5a6b7f;
    margin: 0.4rem 0 0.2rem;
}
.chat-feature-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 0.6rem;
}
.chat-feature-check {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.78rem;
    margin: 0;
}
.chat-feature-check input[type="checkbox"] {
    width: auto;
    margin: 0;
    flex: none;
}
/* 相談種別の変更確認モーダル */
.chat-confirm-overlay {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(15, 30, 50, 0.45);
}
.chat-confirm-box {
    width: min(92%, 360px);
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    padding: 1.1rem 1.1rem 1rem;
    box-sizing: border-box;
}
.chat-confirm-message {
    margin: 0 0 0.9rem;
    font-size: 0.86rem;
    line-height: 1.6;
    color: #1d2b3a;
}
.chat-confirm-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.chat-confirm-yes,
.chat-confirm-no {
    border: none;
    border-radius: 9px;
    padding: 0.6rem 0.8rem;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}
.chat-confirm-yes {
    color: #fff;
    background: #c0392b;
}
.chat-confirm-no {
    color: #1d2b3a;
    background: #eef2f8;
    border: 1px solid #d3ddea;
}
.chat-feature-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 0.7rem;
}
.chat-feature-save,
.chat-feature-add,
.chat-feature-draft,
.chat-feature-sync {
    border: none;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    color: #fff;
    background: #0b4f9f;
    font-size: 0.8rem;
    cursor: pointer;
}
.chat-feature-add {
    background: #1f8a5b;
}
.chat-feature-draft,
.chat-feature-sync {
    background: #4a6fb2;
}
.chat-feature-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 0.65rem;
}
.chat-feature-tools-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
}
.chat-feature-tool {
    padding: 0.5rem 0.7rem;
    border: 1px solid #cdd8e6;
    border-radius: 8px;
    text-decoration: none;
    color: #0b4f9f;
    background: #fff;
}
.chat-feature-tool-card {
    display: flex;
    min-height: 290px;
    flex-direction: column;
    gap: 0.55rem;
    padding: 0.8rem 0.65rem;
    border: 1px solid #cbdcf0;
    border-radius: 8px;
    background: #e5f3ff;
    color: #25364a;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(31, 78, 121, 0.08);
}
.chat-feature-tool-card:hover {
    border-color: #93bbe5;
    box-shadow: 0 5px 14px rgba(31, 78, 121, 0.14);
    transform: translateY(-1px);
}
.chat-feature-tool-image {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 112px;
    padding: 0.25rem;
    background: rgba(255, 255, 255, 0.55);
}
.chat-feature-tool-image img {
    display: block;
    width: 100%;
    max-width: 132px;
    aspect-ratio: 1 / 1;
    object-fit: contain;
}
.chat-feature-tool-description {
    display: block;
    flex: 1 1 auto;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.65;
    color: #344054;
}
.chat-feature-tool-button {
    display: block;
    width: 100%;
    min-height: 42px;
    padding: 0.65rem 0.4rem;
    border-radius: 999px;
    background: #0070d9;
    color: #fff;
    font-size: 0.82rem;
    font-weight: 800;
    line-height: 1.2;
    text-align: center;
}
.chat-feature-list {
    display: grid;
    gap: 0.45rem;
    margin-bottom: 0.7rem;
}
.chat-feature-card-head {
    display: flex;
    justify-content: space-between;
    gap: 0.4rem;
    align-items: center;
    margin-bottom: 0.3rem;
}
.chat-feature-empty {
    padding: 0.55rem 0.65rem;
    border: 1px dashed #cdd8e6;
    border-radius: 8px;
    background: #fff;
    color: #667085;
}

.chat-widget-input-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: stretch;
    gap: 0.65rem;
    padding: 0.65rem 0.85rem;
    border-top: 1px solid #d9e4f2;
    background: linear-gradient(180deg, #fff 0%, #f6f9fd 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}
.chat-widget-input {
    flex: 1;
    min-width: 0;
    min-height: 64px;
    padding: 0.72rem 0.85rem;
    border: 1px solid #cfd8e3;
    border-radius: 10px;
    background: #fff;
    color: #101828;
    /* iOS は16px未満の入力欄にフォーカスすると自動ズームし、送信後も倍率が戻らない。
       16px以上にしてズーム自体を抑止する。 */
    font-size: 16px;
    line-height: 1.55;
    resize: none;
    font-family: inherit;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.chat-widget-input:focus {
    outline: none;
    border-color: #0b4f9f;
    box-shadow: 0 0 0 3px rgba(11, 79, 159, 0.14), 0 1px 2px rgba(16, 24, 40, 0.05);
}
.chat-widget-input::placeholder {
    color: #98a2b3;
}
.chat-widget-input:disabled {
    background: #f1f3f5;
    cursor: not-allowed;
}
.chat-widget-voice,
.chat-widget-send {
    width: 100%;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.chat-widget-send-icon {
    width: 1.1em;
    height: 1.1em;
    object-fit: contain;
    flex-shrink: 0;
}
.chat-widget-voice {
    height: 42px;
    padding: 0;
    border: 1px solid #bfd7f3;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    color: #0066cc;
    font-size: 1.08rem;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
.chat-widget-voice-icon {
    display: inline-flex;
    width: 20px;
    height: 20px;
    align-items: center;
    justify-content: center;
}
.chat-widget-voice-icon svg {
    width: 20px;
    height: 20px;
    display: block;
    fill: currentColor;
}
.chat-widget-voice:hover {
    background: #e8f0fe;
    border-color: #8cbff0;
    transform: translateY(-1px);
}
.chat-widget-voice.is-listening {
    background: #d92d20;
    border-color: #d92d20;
    color: #fff;
    box-shadow: 0 0 0 4px rgba(217, 45, 32, 0.16);
}
.chat-widget-voice.is-unsupported {
    display: none;
}
.chat-widget-send {
    min-height: 42px;
    padding: 0.55rem 0.8rem;
    border: 1px solid #0066cc;
    background: #0066cc;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 102, 204, 0.22);
}
.chat-widget-send:hover {
    background: #0052a3;
    border-color: #0052a3;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 82, 163, 0.24);
}
.chat-widget-voice:disabled,
.chat-widget-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
.chat-widget-voice-status {
    padding: 0 1rem 0.65rem;
    background: #f9f9f9;
    color: #475467;
    font-size: 0.78rem;
    line-height: 1.45;
}
.chat-widget-voice-status[hidden] {
    display: none !important;
}

.chat-msg.chat-msg-loading .chat-msg-bubble::after {
    content: '...';
    animation: chat-dots 1s steps(4, end) infinite;
}
@keyframes chat-dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

.chat-widget-root.chat-widget-chat-only {
    --chat-widget-root-bottom: 0px;
    --chat-widget-toggle-height: 0px;
    --chat-widget-panel-gap: 0px;
    --chat-widget-panel-margin: 0px;
    position: fixed;
    inset: 0;
    right: auto;
    bottom: auto !important;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    z-index: 9999;
    transition: none;
}

.chat-widget-root.chat-widget-chat-only .chat-widget-toggle {
    display: none;
}

.chat-widget-root.chat-widget-chat-only .chat-widget-panel {
    position: fixed;
    inset: 0;
    right: auto;
    bottom: auto;
    width: 100vw;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
}

.chat-widget-root.chat-widget-chat-only .chat-widget-header {
    padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
}

.chat-widget-root.chat-widget-chat-only .chat-widget-close {
    display: none;
}

.chat-widget-root.chat-widget-chat-only .chat-widget-messages {
    min-height: 0;
}

.chat-widget-root.chat-widget-chat-only .chat-widget-input-wrap {
    padding-bottom: calc(0.65rem + env(safe-area-inset-bottom, 0px));
}

.chat-widget-root.chat-widget-chat-only .chat-widget-voice-status {
    padding-bottom: calc(0.65rem + env(safe-area-inset-bottom, 0px));
}

@media (max-width: 480px) {
    .chat-widget-root {
        --chat-widget-toggle-height: 56px;
        right: 0.75rem;
    }

    .chat-widget-root.is-pwa-modal-visible {
        --chat-widget-root-bottom: var(--chat-widget-pwa-bottom, 22rem);
    }

    .chat-widget-panel {
        position: fixed;
        top: var(--chat-visual-viewport-top, 0px);
        right: 0;
        bottom: auto;
        left: 0;
        width: auto;
        height: var(--chat-visual-viewport-height, 100dvh);
        max-height: none;
        border-radius: 0;
    }

    /* キーボード表示中は会話と入力欄を優先し、7項目のメニューを一時的に退避する。 */
    .chat-widget-root.is-keyboard-open .chat-widget-tabbar {
        display: none;
    }

    .chat-widget-root.is-keyboard-open .chat-widget-input-wrap {
        margin-bottom: max(0.35rem, env(safe-area-inset-bottom, 0px));
    }

    .chat-widget-toggle {
        min-width: min(90vw, 320px);
        height: 56px;
        padding-right: 0.9rem;
    }
    .chat-widget-toggle-avatar {
        width: 44px;
        height: 44px;
        flex-basis: 44px;
    }
    .chat-widget-toggle-owner {
        font-size: 12px;
    }
    .chat-widget-toggle-label {
        font-size: 17px;
    }

    .chat-widget-input-wrap {
        grid-template-columns: 1fr;
        gap: 0.55rem;
        padding: 0.75rem;
    }

    .chat-widget-input {
        min-height: 76px;
    }

    .chat-widget-input-actions {
        width: 100%;
        flex-basis: auto;
        flex-direction: row;
        justify-content: flex-end;
    }

    .chat-widget-voice {
        width: 46px;
        height: 42px;
    }

    .chat-widget-send {
        width: auto;
        min-width: 96px;
    }
}

/* Chat screen layout matching the formal AI chat mockup */
.chat-widget-panel {
    width: min(96vw, 430px);
    height: min(80dvh, 890px);
    max-height: min(88dvh, 890px);
    border: 1px solid #dfe8f4;
    border-radius: 18px;
    background: #fff;
}

.chat-widget-header {
    /* 上部の青いバーの上下を短縮（高さ・余白を圧縮） */
    min-height: 56px;
    align-items: center;
    padding: 0.4rem 0.8rem 0.45rem;
    background: linear-gradient(135deg, #0757d7 0%, #0044bd 54%, #075fdd 100%);
    gap: 0.85rem;
}

.chat-widget-avatar {
    width: 55px;
    height: 55px;
    border: 2px solid rgba(255, 255, 255, 0.86);
    box-shadow: 0 8px 22px rgba(0, 35, 93, 0.22);
}

.chat-widget-agent-name {
    font-size: 1.2rem;
    font-weight: 800;
    line-height: 1.16;
    letter-spacing: 0;
}

.chat-widget-role {
    display: block;
    margin-top: 0.1rem;
    font-size: 0.8rem;
    font-weight: 800;
    line-height: 1.2;
}

/* 「あなた専用のAIエージェント」であることを上部の青いバーで伝える表示。
   顧客名が判明している場合だけ付与される（syncAgentHeader）。 */
.chat-widget-role.is-personalized {
    display: inline-block;
    margin-top: 0.24rem;
    padding: 0.16rem 0.6rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.22);
    font-size: 0.72rem;
    word-break: break-word;
}

.chat-widget-badge {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    margin-top: 0.42rem;
    padding: 0.2rem 0.72rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    font-size: 0.64rem;
    font-weight: 800;
    line-height: 1.25;
}

.chat-widget-header-actions {
    gap: 0.7rem;
}

.chat-widget-icon-btn {
    border: 1px solid rgba(255, 255, 255, 0.88);
    background: rgba(0, 65, 175, 0.08);
}

.chat-widget-icon-btn svg {
    width: 20px;
    height: 20px;
}

.chat-widget-close {
    font-size: 1.5rem;
    font-weight: 300;
}

.chat-widget-messages {
    padding: 1.05rem 0.95rem 0.75rem;
    gap: 0.86rem;
    background: #fff;
}

.chat-msg {
    max-width: 100%;
}

.chat-msg .chat-msg-avatar {
    width: 38px;
    height: 38px;
    margin-top: 0.25rem;
    box-shadow: 0 3px 12px rgba(20, 56, 101, 0.12);
}

.chat-msg-content {
    max-width: calc(100% - 48px);
}

.chat-msg-bubble {
    padding: 0.82rem 1rem;
    border-radius: 14px;
    font-size: 0.96rem;
    line-height: 1.76;
}

.chat-msg.bot .chat-msg-bubble {
    background: #fff;
    border: 1px solid #dfe8f4;
    color: #0d1117;
    box-shadow: 0 8px 22px rgba(15, 48, 90, 0.06);
    border-bottom-left-radius: 5px;
}

.chat-msg.user .chat-msg-bubble {
    background: #edf6ff;
    color: #0d1117;
    border-bottom-right-radius: 5px;
}

.chat-msg-time {
    color: #8b96a8;
    font-size: 0.76rem;
}

.chat-widget-quick-actions {
    max-height: 104px;
    padding: 0.05rem 0.95rem;
    border-top: 0;
}

.chat-widget-input-wrap {
    margin: 0.25rem 0.8rem 0.75rem;
    padding: 0.64rem;
    border: 1.5px solid #0757d7;
    border-radius: 9px;
    background: #fff;
    box-shadow: none;
}

.chat-widget-input {
    min-height: 64px;
    padding: 0.2rem 0.2rem 0.45rem;
    border: 0;
    border-bottom: 1px dashed #d7e2f0;
    border-radius: 0;
    box-shadow: none;
}

.chat-widget-input:focus {
    box-shadow: none;
}

.chat-widget-input-actions {
    width: 80px;
    flex-basis: 62px;
    justify-content: flex-end;
}

.chat-widget-voice {
    width: 34px;
    height: 34px;
    border-radius: 50%;
}

.chat-widget-send {
    min-height: 34px;
    border-radius: 999px;
    padding: 0.36rem 0.76rem;
    background: #0757d7;
    border-color: #0757d7;
}

.chat-widget-tabbar {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.34rem;
    /* 下部のボタン列は常に固定で表示し、縮めない */
    flex-shrink: 0;
    /* スマホの曲線の角や、ホームバー（セーフエリア）に
       左右端のボタン（AI担当・担当連絡）がかからないよう、
       端末のセーフエリア + 約2mm 分だけ底上げする。 */
    padding: 0 0.8rem calc(0.42rem + 2mm + env(safe-area-inset-bottom, 0px));
    background: #fff;
}

.chat-widget-tab {
    min-width: 0;
    min-height: 76px;
    padding: 0.4rem 0.2rem 0.34rem;
    border: 1px solid #dfe8f4;
    border-radius: 8px;
    background: #fff;
    color: #0757d7;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.18rem;
    font: inherit;
    font-size: clamp(0.62rem, 2.3vw, 0.65rem);
    font-weight: 800;
    line-height: 1.18;
    text-align: center;
}

.chat-widget-tab:hover,
.chat-widget-tab.is-active {
    background: #f4f9ff;
    border-color: #c9def7;
}

/* 接続中・ユーザー認識中はAI担当以外のタブを操作不可にする（スタック防止・身元不明操作の防止）。 */
.chat-widget-tab.is-locked {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.chat-widget-tab-icon {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.chat-widget-tab-icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

.chat-widget-tab-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.chat-widget-screen-note {
    margin: 0;
    padding: 0 0.8rem calc(0.62rem + env(safe-area-inset-bottom, 0px));
    color: #8b96a8;
    background: #fff;
    font-size: 0.72rem;
    line-height: 1.4;
    text-align: center;
}

.chat-widget-root.chat-widget-chat-only .chat-widget-panel {
    width: 100vw;
    height: 100dvh;
    max-height: none;
    border: 0;
    border-radius: 0;
}

.chat-widget-root.chat-widget-chat-only .chat-widget-header {
    padding-top: calc(1rem + env(safe-area-inset-top, 0px));
}

@media (max-width: 480px) {
    .chat-widget-header {
        /* スマホでも青いバーの上下を短縮 */
        min-height: 64px;
        padding: 0.45rem 0.95rem;
    }

    .chat-widget-avatar {
        width: 50px;
        height: 50px;
    }

    .chat-widget-agent-name {
        font-size: 1.2rem;
    }

    .chat-widget-role {
        font-size: 0.92rem;
    }

    .chat-widget-icon-btn {
        width: 44px;
        height: 44px;
    }

    .chat-widget-input-wrap {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 0.5rem;
        margin-inline: 0.72rem;
    }

    .chat-widget-input-actions {
        width: 75px;
        flex-direction: column;
    }

    .chat-widget-send {
        width: 100%;
        min-width: 0;
    }

    .chat-widget-tabbar {
        overflow-x: auto;
        grid-template-columns: repeat(7, minmax(40px, 1fr));
        padding-inline: 0.7rem;
    }

    .chat-widget-tab {
        min-height: 70px;
    }
    .chat-widget-feature-panel {
        max-height: 180px;
    }
    .chat-widget-panel.is-feature-view .chat-widget-feature-panel {
        max-height: none;
    }
    .chat-feature-grid {
        grid-template-columns: 1fr;
    }
    .chat-feature-tools-grid {
        gap: 0.55rem;
    }
    .chat-feature-tool-card {
        min-height: 270px;
        padding: 0.7rem 0.55rem;
    }
    .chat-feature-tool-description {
        font-size: 0.74rem;
        line-height: 1.55;
    }
    .chat-feature-tool-button {
        min-height: 38px;
        font-size: 0.76rem;
    }
}

@media (max-width: 480px) {
    .chat-widget-panel {
        width: 100vw;
        height: 100dvh;
        max-height: none;
        border: 0;
        border-radius: 0;
    }
}

/* ===== 担当連絡：担当（人間）メッセージ・添付・通知バッジ ===== */
.chat-msg.agent { display: flex; align-items: flex-start; gap: 8px; }
.chat-msg.agent .chat-msg-content { max-width: 80%; }
.chat-msg-agent-label {
    font-size: 0.72rem;
    color: #06794a;
    font-weight: 700;
    margin-bottom: 2px;
}
.chat-msg.agent .chat-msg-bubble {
    background: #06c755;
    color: #fff;
    border: none;
}
.chat-msg-attachments { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.chat-msg-attach { display: inline-block; }
.chat-msg-attach-image img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 10px;
    border: 1px solid #ddd;
    display: block;
}
.chat-msg-attach-file {
    padding: 6px 10px;
    background: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 10px;
    font-size: 0.85rem;
    text-decoration: none;
    color: #333;
}

.chat-widget-attach {
    border: none;
    background: #f0f0f0;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    color: #555;
}
.chat-widget-attach:hover { background: #e3e3e3; }
.chat-widget-attach-list { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px; }
.chat-widget-pending {
    background: #eef0f3;
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 0.78rem;
}
.chat-widget-pending button {
    border: none;
    background: none;
    cursor: pointer;
    color: #e8443a;
    font-weight: 700;
    margin-left: 4px;
}

/* 送信前プレビュー（添付カード）。画像はサムネイル付き。 */
.chat-widget-attach-list:not(:empty),
.chat-contact-attach-list:not(:empty) {
    padding-top: 6px;
    padding-bottom: 6px;
}
.chat-pending-card {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid #d9e4f2;
    border-radius: 10px;
    padding: 5px 6px 5px 5px;
    max-width: 240px;
    box-shadow: 0 1px 3px rgba(18, 52, 99, 0.08);
}
.chat-pending-thumb {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #eef4fb;
}
.chat-pending-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-pending-icon { font-size: 22px; line-height: 1; }
.chat-pending-meta { display: flex; flex-direction: column; min-width: 0; }
.chat-pending-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: #1f2d3d;
    max-width: 132px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-pending-size { font-size: 0.68rem; color: #7a8699; }
.chat-pending-x {
    flex: 0 0 auto;
    border: none;
    background: #eef0f3;
    color: #33415c;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: 700;
    line-height: 1;
    transition: background 0.15s;
}
.chat-pending-x:hover { background: #dde3ec; }

/* 送信済みメッセージ内の画像プレビューを少し大きく見やすく */
.chat-msg-attach-image img {
    border-radius: 10px;
    border: 1px solid #e1e8f1;
}

.chat-widget-tab { position: relative; }
.chat-tab-unread {
    position: absolute;
    top: 2px;
    right: 6px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: #e8443a;
    color: #fff;
    border-radius: 999px;
    font-size: 0.68rem;
    line-height: 16px;
    text-align: center;
    font-weight: 700;
}

/* チャットを閉じている間の未読バッジ（担当連絡＋物件選定の合計）。
   起動ボタンの外に少しはみ出させて、画面を見ただけで新着に気づけるようにする。 */
.chat-widget-toggle { position: relative; }
.chat-widget-toggle-unread {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    background: #e8443a;
    color: #fff;
    border: 2px solid #fff;
    border-radius: 999px;
    font-size: 0.7rem;
    line-height: 16px;
    text-align: center;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* 担当連絡：顧客側の「既読」表示（自分の発言に付く）
   タイムスタンプは日付＋時刻（2026/7/29 13:39:18）を表示するため、狭い画面で
   「編集済み」「既読」と横並びに収まらないことがある。折り返しを許可する。 */
.chat-msg.user .chat-msg-time { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.chat-contact-read-wrap { display: inline-flex; }
.chat-contact-read {
    font-size: 0.68rem;
    color: #06794a;
    font-weight: 700;
}
.chat-contact-read[hidden] { display: none; }

/* 担当連絡：メッセージの「編集」「取り消し」操作・編集フォーム・取り消し表示 */
.chat-contact-msg-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 3px;
}
.chat-contact-msg-action {
    border: none;
    background: none;
    padding: 0;
    font: inherit;
    font-size: 0.7rem;
    color: #0b5394;
    cursor: pointer;
    text-decoration: underline;
}
.chat-contact-msg-action:hover { color: #08305c; }

/* 「編集済み」マーク */
.chat-msg-edited {
    font-size: 0.66rem;
    color: #98a2b3;
}

/* 取り消し済みの吹き出し（本文をマスクし、淡色のイタリックで表示） */
.chat-msg-bubble-deleted {
    background: #eef1f5 !important;
    color: #8b96a8 !important;
    font-style: italic;
    border: 1px dashed #cdd6e2 !important;
}

/* インライン編集フォーム */
.chat-contact-edit {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.chat-contact-edit-input {
    width: 100%;
    min-height: 60px;
    resize: none;
    border: 1px solid #cdd8e6;
    border-radius: 10px;
    padding: 0.5rem 0.65rem;
    /* iOSの自動ズーム防止のため16px以上 */
    font-size: 16px;
    font-family: inherit;
    line-height: 1.4;
    box-sizing: border-box;
}
.chat-contact-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.chat-contact-edit-cancel,
.chat-contact-edit-save {
    border: 1px solid #0757d7;
    border-radius: 999px;
    padding: 0.28rem 0.85rem;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
}
.chat-contact-edit-cancel {
    background: #fff;
    color: #0757d7;
}
.chat-contact-edit-save {
    background: #0757d7;
    color: #fff;
}

/* ===== PC（デスクトップ）：AIエージェント画面の移動・サイズ変更 =====
   PCでは右下固定・サイズ固定だと「担当連絡」などのやり取りが見づらいため、
   ヘッダーのドラッグで移動、四辺・四隅のドラッグでサイズ変更できるようにする。
   スマホ・タブレット（〜768px）とチャット専用表示は従来どおり固定のまま。 */
.chat-widget-resize-handle {
    display: none;
    position: absolute;
    z-index: 6;
    background: transparent;
}
.chat-widget-expand {
    display: none;
}

@media (min-width: 769px) {
    .chat-widget-root:not(.chat-widget-chat-only) .chat-widget-expand {
        display: inline-flex;
    }

    /* ヘッダーはドラッグで移動できる領域 */
    .chat-widget-root:not(.chat-widget-chat-only) .chat-widget-header {
        cursor: move;
    }
    .chat-widget-root:not(.chat-widget-chat-only) .chat-widget-header .chat-widget-icon-btn {
        cursor: pointer;
    }

    /* 位置・サイズをユーザーが変更した状態（left/top/width/height はJSが指定） */
    .chat-widget-root:not(.chat-widget-chat-only) .chat-widget-panel.is-user-positioned {
        position: fixed;
        /* JSが指定する width/height に枠線を含めるため（ズレ防止） */
        box-sizing: border-box;
        right: auto;
        bottom: auto;
        width: auto;
        max-width: none;
        height: auto;
        max-height: none;
    }

    .chat-widget-root:not(.chat-widget-chat-only) .chat-widget-resize-handle {
        display: block;
    }
    .chat-widget-resize-handle:hover {
        background: rgba(11, 79, 159, 0.18);
    }
    .chat-widget-resize-handle-n {
        top: 0;
        left: 0;
        right: 0;
        height: 6px;
        cursor: ns-resize;
    }
    .chat-widget-resize-handle-s {
        bottom: 0;
        left: 0;
        right: 0;
        height: 6px;
        cursor: ns-resize;
    }
    .chat-widget-resize-handle-e {
        top: 0;
        bottom: 0;
        right: 0;
        width: 6px;
        cursor: ew-resize;
    }
    .chat-widget-resize-handle-w {
        top: 0;
        bottom: 0;
        left: 0;
        width: 6px;
        cursor: ew-resize;
    }
    /* 四隅は辺より後ろに配置して優先的に掴めるようにする */
    .chat-widget-resize-handle-ne {
        top: 0;
        right: 0;
        width: 14px;
        height: 14px;
        cursor: nesw-resize;
    }
    .chat-widget-resize-handle-nw {
        top: 0;
        left: 0;
        width: 14px;
        height: 14px;
        cursor: nwse-resize;
    }
    .chat-widget-resize-handle-se {
        bottom: 0;
        right: 0;
        width: 14px;
        height: 14px;
        cursor: nwse-resize;
    }
    .chat-widget-resize-handle-sw {
        bottom: 0;
        left: 0;
        width: 14px;
        height: 14px;
        cursor: nesw-resize;
    }
}

/* 拡大／元に戻すボタンのアイコン切り替え */
.chat-widget-expand .chat-widget-expand-icon-collapse {
    display: none;
}
.chat-widget-expand.is-maximized .chat-widget-expand-icon-expand {
    display: none;
}
.chat-widget-expand.is-maximized .chat-widget-expand-icon-collapse {
    display: block;
}

/* ドラッグ中はテキスト選択を止めて、ハンドルの当たり判定を安定させる */
.chat-widget-root.is-panel-dragging,
.chat-widget-root.is-panel-dragging * {
    user-select: none;
    -webkit-user-select: none;
}
.chat-widget-root.is-panel-dragging .chat-widget-panel {
    transition: none;
}
