.towa-ai-chat { position: relative; z-index: 1060; font-family: inherit; }
.towa-ai-chat__launcher { position: fixed; right: 22px; bottom: 22px; z-index: 1040; display: flex; align-items: center; gap: 10px; min-height: 62px; padding: 8px 15px 8px 8px; border: 1px solid rgba(15,23,42,.12); border-radius: 999px; background: rgba(255,255,255,.96); box-shadow: 0 16px 42px rgba(15,23,42,.18); opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(0); transition: opacity .5s ease, transform .2s ease, box-shadow .2s ease, visibility 0s linear .5s; }
.towa-ai-chat.is-visible-on-bottom .towa-ai-chat__launcher { opacity: .96; visibility: visible; pointer-events: auto; transition: opacity .5s ease, transform .2s ease, box-shadow .2s ease, visibility 0s linear 0s; }
.towa-ai-chat__launcher:hover { transform: translateY(-2px); box-shadow: 0 18px 50px rgba(15,23,42,.23); }
.towa-ai-chat__launcher-icon { position: relative; width: 48px; height: 48px; flex: 0 0 48px; overflow: hidden; border-radius: 50%; background: linear-gradient(145deg,#eef2ff,#e0f2fe); display: grid; place-items: center; }
.towa-ai-chat__launcher-icon img { width: 100%; height: 100%; object-fit: cover; }
.towa-ai-chat__launcher-text { display: flex; flex-direction: column; text-align: left; line-height: 1.25; }
.towa-ai-chat__launcher-text strong { font-size: .9rem; color: #0f172a; }
.towa-ai-chat__launcher-text small { color: #64748b; font-size: .72rem; }
.towa-ai-chat__local-image-fallback { display: none; color: #334155; font-size: 1.35rem; }
.is-local-image-missing > img { display: none !important; }
.is-local-image-missing > .towa-ai-chat__local-image-fallback { display: grid; }

.towa-ai-chat__modal { z-index: 1090; }
.towa-ai-chat__modal .modal-dialog { max-width: 1180px; padding: 16px; }
.towa-ai-chat__modal-content { position: relative; overflow: hidden; border: 0; border-radius: 28px; box-shadow: 0 28px 90px rgba(15,23,42,.25); background: #fff; }
.towa-ai-chat__aurora { position: absolute; inset: 0 0 auto; height: 180px; pointer-events: none; background: radial-gradient(circle at 15% 0%,rgba(99,102,241,.16),transparent 45%), radial-gradient(circle at 80% 10%,rgba(14,165,233,.12),transparent 40%); }
.towa-ai-chat__close { position: absolute; right: 16px; top: 16px; z-index: 8; width: 40px; height: 40px; border: 0; border-radius: 50%; background: rgba(255,255,255,.9); box-shadow: 0 5px 18px rgba(15,23,42,.12); }
.towa-ai-chat__modal-body { position: relative; z-index: 1; padding: 30px; }
.towa-ai-chat__modal-grid { display: grid; grid-template-columns: minmax(300px,.9fr) minmax(360px,1.1fr); gap: 26px; }

.towa-ai-chat__concierge-column { min-width: 0; }
.towa-ai-chat__stage { position: relative; border-radius: 24px; overflow: hidden; background: linear-gradient(160deg,#f8fafc,#e2e8f0); border: 1px solid rgba(148,163,184,.24); }
.towa-ai-chat__stage-visual { position: relative; aspect-ratio: 16 / 10; min-height: 300px; display: grid; place-items: center; overflow: hidden; }
.towa-ai-chat__stage-visual > img,
.towa-ai-chat__stage-visual > video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.towa-ai-chat__stage-visual > img { z-index: 1; }
.towa-ai-chat__stage-visual > [data-ai-chat-avatar-video] { z-index: 3; }
.towa-ai-chat__stage-visual > video[hidden] { display: none; }
.towa-ai-chat__stage-fallback { position: absolute; inset: 0; z-index: 0; display: grid; place-content: center; justify-items: center; gap: 7px; color: #475569; background: linear-gradient(145deg,#f8fafc,#eef2ff); }
.towa-ai-chat__stage-fallback i { font-size: 3.2rem; }
.towa-ai-chat__stage-fallback strong { letter-spacing: .12em; font-size: 1.1rem; }
.towa-ai-chat__stage-fallback small { font-size: .78rem; }
.towa-ai-chat__brand-watermark { position: absolute; left: 16px; top: 16px; z-index: 5; }
.towa-ai-chat__brand-mark { display: inline-flex; padding: 6px 9px; border-radius: 999px; background: rgba(15,23,42,.68); color: #fff; letter-spacing: .12em; font-size: .68rem; font-weight: 800; }
.towa-ai-chat__avatar-wave { position: absolute; right: 16px; bottom: 16px; z-index: 6; display: flex; align-items: end; gap: 3px; height: 28px; padding: 6px 8px; border-radius: 999px; background: rgba(15,23,42,.68); }
.towa-ai-chat__avatar-wave[hidden] { display: none; }
.towa-ai-chat__avatar-wave span { display: block; width: 3px; height: 8px; border-radius: 4px; background: #fff; animation: towa-wave .8s ease-in-out infinite alternate; }
.towa-ai-chat__avatar-wave span:nth-child(2) { animation-delay: .12s; }
.towa-ai-chat__avatar-wave span:nth-child(3) { animation-delay: .24s; }
.towa-ai-chat__avatar-wave span:nth-child(4) { animation-delay: .36s; }
@keyframes towa-wave { to { height: 20px; } }
.towa-ai-chat__avatar-status { display: flex; gap: 8px; align-items: center; padding: 11px 14px; color: #334155; font-size: .82rem; background: #fff; border-top: 1px solid rgba(148,163,184,.2); }
.towa-ai-chat__avatar-status > span { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; }
.towa-ai-chat__avatar-status.is-listen > span { background: #0ea5e9; box-shadow: 0 0 0 5px rgba(14,165,233,.12); }
.towa-ai-chat__avatar-status.is-thinking > span { background: #8b5cf6; box-shadow: 0 0 0 5px rgba(139,92,246,.12); }
.towa-ai-chat__avatar-status.is-speaking > span { background: #10b981; box-shadow: 0 0 0 5px rgba(16,185,129,.12); }

.towa-ai-chat__concierge-controls { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-top: 16px; }
.towa-ai-chat__concierge-status { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.towa-ai-chat__concierge-status strong { color: #0f172a; font-size: .98rem; }
.towa-ai-chat__concierge-status small { color: #64748b; font-size: .76rem; line-height: 1.5; }
.towa-ai-chat__media-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.towa-ai-chat__voice-toggle,
.towa-ai-chat__mic-toggle { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 11px; border-radius: 999px; border: 1px solid #cbd5e1; background: #fff; color: #334155; font-size: .78rem; font-weight: 700; }
.towa-ai-chat__mic-toggle.is-listening { border-color: #0ea5e9; box-shadow: 0 0 0 4px rgba(14,165,233,.1); }
.towa-ai-chat__voice-toggle[aria-pressed="true"] { border-color: #a5b4fc; background: #eef2ff; color: #4338ca; }
.towa-ai-chat__avatar-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 13px; }
.towa-ai-chat__avatar-meta span { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 999px; background: #f8fafc; color: #475569; font-size: .69rem; border: 1px solid #e2e8f0; }
.towa-ai-chat__saving-note,
.towa-ai-chat__ai-voice-note { margin: 10px 0 0; display: flex; gap: 8px; color: #64748b; font-size: .72rem; line-height: 1.45; }

.towa-ai-chat__conversation-column { min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.towa-ai-chat__status { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 14px; background: #f8fafc; color: #475569; font-size: .78rem; }
.towa-ai-chat__pulse { width: 8px; height: 8px; border-radius: 50%; background: #10b981; box-shadow: 0 0 0 5px rgba(16,185,129,.1); }
.towa-ai-chat__messages { height: 390px; margin-top: 14px; padding: 5px 4px 10px; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.towa-ai-chat__message { display: flex; }
.towa-ai-chat__message.is-user { justify-content: flex-end; }
.towa-ai-chat__bubble { max-width: 88%; padding: 11px 13px; border-radius: 16px 16px 16px 5px; background: #f1f5f9; color: #1e293b; font-size: .88rem; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.towa-ai-chat__message.is-user .towa-ai-chat__bubble { background: #312e81; color: #fff; border-radius: 16px 16px 5px 16px; }
.towa-ai-chat__message.is-media-notice .towa-ai-chat__bubble { max-width: 100%; padding: 8px 11px; background: #fffbeb; color: #92400e; font-size: .75rem; }
.towa-ai-chat__typing-dot { display: inline-block; width: 7px; height: 7px; margin: 0 2px; border-radius: 50%; background: #64748b; animation: towa-dot .8s ease-in-out infinite alternate; }
.towa-ai-chat__typing-dot:nth-child(2) { animation-delay: .15s; }
.towa-ai-chat__typing-dot:nth-child(3) { animation-delay: .3s; }
@keyframes towa-dot { to { transform: translateY(-5px); opacity: .45; } }

.towa-ai-chat__quota { margin: 8px 0 10px; padding: 9px 11px; border-radius: 12px; background: #f8fafc; color: #64748b; display: flex; justify-content: space-between; gap: 10px; font-size: .75rem; }
.towa-ai-chat__quota.is-exhausted { background: #fff7ed; color: #9a3412; }
.towa-ai-chat__quota-copy { display: flex; gap: 7px; align-items: flex-start; }
.towa-ai-chat__quota-link { color: inherit; font-weight: 700; white-space: nowrap; }
.towa-ai-chat__form { display: grid; grid-template-columns: 1fr auto; gap: 9px; align-items: end; }
.towa-ai-chat__input-shell { position: relative; }
.towa-ai-chat__form textarea { width: 100%; min-height: 78px; max-height: 150px; resize: none; padding: 11px 56px 11px 12px; border: 1px solid #cbd5e1; border-radius: 16px; outline: none; font: inherit; font-size: .88rem; }
.towa-ai-chat__form textarea:focus { border-color: #818cf8; box-shadow: 0 0 0 4px rgba(99,102,241,.1); }
.towa-ai-chat__input-count { position: absolute; right: 11px; bottom: 8px; color: #94a3b8; font-size: .68rem; }
.towa-ai-chat__form > button { min-height: 48px; padding: 0 15px; border: 0; border-radius: 14px; background: #312e81; color: #fff; display: inline-flex; align-items: center; gap: 7px; font-weight: 700; }
.towa-ai-chat__form > button:disabled { opacity: .5; cursor: not-allowed; }

@media (max-width: 900px) {
    .towa-ai-chat__modal .modal-dialog { padding: 6px; }
    .towa-ai-chat__modal-body { padding: 22px 16px 16px; }
    .towa-ai-chat__modal-grid { grid-template-columns: 1fr; }
    .towa-ai-chat__stage-visual { min-height: 240px; }
    .towa-ai-chat__messages { height: 300px; }
    .towa-ai-chat__concierge-controls { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 560px) {
    .towa-ai-chat__launcher { right: 12px; bottom: 12px; min-height: 54px; }
    .towa-ai-chat__launcher-icon { width: 40px; height: 40px; flex-basis: 40px; }
    .towa-ai-chat__launcher-text small { display: none; }
    .towa-ai-chat__modal .modal-dialog { margin: 0; max-width: none; min-height: 100%; align-items: stretch; }
    .towa-ai-chat__modal-content { border-radius: 0; min-height: 100vh; }
    .towa-ai-chat__stage-visual { min-height: 210px; }
    .towa-ai-chat__messages { height: 260px; }
    .towa-ai-chat__form { grid-template-columns: 1fr; }
    .towa-ai-chat__form > button { justify-content: center; }
}

/* V9 Azure media policy: keep the local idle poster untouched until a realtime answer starts. */
.towa-ai-chat__stage-visual > img[data-ai-chat-avatar-poster],
.towa-ai-chat__stage-visual > video {
    transform: none !important;
    filter: none !important;
    opacity: 1 !important;
    animation: none !important;
    transition: none !important;
}
