#tw-ai-assistant-root {
    position: fixed;
    right: 12px;
    bottom: 12px;
    z-index: 9999;
    font-family: 'Noto Sans JP', sans-serif;
}

.tw-ai-button {
    background: rgba(0, 0, 0, 0);
    color: #fff;
    border: none;
    border-radius: 999px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tw-ai-button:hover {
    transform: translateY(-1px);
}

.tw-ai-button img{
    width: 200px;
}

.tw-ai-panel {
    display: none;
    width: min(360px, calc(100vw - 24px));
    max-height: 520px;
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.16);
    overflow: hidden;
    margin-top: 12px;
}

.tw-ai-panel--open {
    display: flex;
    flex-direction: column;
}

.tw-ai-panel__header {
    background: #d1684f;
    color: #fff;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.tw-ai-panel__header strong {
    display: block;
    font-size: 1.1rem;
    letter-spacing: 0.04em;
}

.tw-ai-panel__header p {
    margin: 8px 0 0;
    font-size: 0.88rem;
    line-height: 1.6;
    max-width: 230px;
}

.tw-ai-close {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 2.2rem;
    line-height: 1;
}

.tw-ai-close::before {
    content: '×';
    display: block;
    transform: translateY(-2px);
}

.tw-ai-messages {
    flex: 1;
    min-height: 0;
    padding: 18px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #faf5f1;
}

.tw-ai-message {
    max-width: 100%;
    display: flex;
}

.tw-ai-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.tw-ai-message--bot {
    flex-direction: column;
}

.tw-ai-message--user {
    justify-content: flex-end;
}

.tw-ai-message--bot .tw-ai-message__text,
.tw-ai-message--user .tw-ai-message__text {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 22px;
    font-size: 0.95rem;
    line-height: 1.6;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
}

.tw-ai-message--bot .tw-ai-message__text {
    background: #fff;
    color: #333;
}

.tw-ai-message--user .tw-ai-message__text {
    background: #d1684f;
    color: #fff;
    align-self: flex-end;
}

.tw-ai-message__cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tw-ai-card {
    background: #fff;
    border-radius: 18px;
    display: flex;
    overflow: hidden;
    border: 1px solid rgba(209, 104, 79, 0.14);
}

.tw-ai-card__image {
    width: 35%;
    min-width: 35%;
    max-height: 110px;
    overflow: hidden;
}

.tw-ai-card__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.tw-ai-card__body {
    width: 65%;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    min-width: 0;
}

.tw-ai-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.tw-ai-quick-reply {
    border: 1px solid #d1684f;
    background: transparent;
    color: #d1684f;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.tw-ai-quick-reply:hover,
.tw-ai-quick-reply:focus {
    background: rgba(209, 104, 79, 0.08);
    outline: none;
}

@media (max-width: 520px) {
    /* .tw-ai-card {
        flex-direction: column;
    } */

    /* .tw-ai-card__image,
    .tw-ai-card__body {
        width: 100%;
        min-width: 0;
    } */

    .tw-ai-card__body {
        padding: 10px 12px;
    }
}

.tw-ai-card__meta {
    font-size: 0.7rem;
    color: #999;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.tw-ai-card__title {
    font-size: 0.9rem;
    color: #222;
    font-weight: 700;
    margin: 0;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3; 
    overflow: hidden;
    text-overflow: ellipsis;
}

/* .tw-ai-card__excerpt {
    margin: 0;
    color: #5b5b5b;
    font-size: 0.8rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
} */

.tw-ai-card__link {
    color: #d1684f;
    font-size: 0.86rem;
    text-decoration: none;
    margin-top: auto;
    font-weight: 700;
}

.tw-ai-map-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 50%;
    text-decoration: none;
    margin: 8px 8px 0 0;
    box-shadow: 0 6px 18px rgba(0,0,0,0.06);
}

.twh-map-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.tw-ai-map-label {
    font-size: 0.92rem;
    color: #222;
    font-weight: 700;
}

.tw-ai-map-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px 8px 12px;
    background: #fff;
    border-radius: 20px;
    text-decoration: none;
    margin: 6px 6px 0 0;
    box-shadow: 0 6px 18px rgba(0,0,0,0.06);
}

.tw-ai-maps-section {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.tw-ai-coupon-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.tw-ai-coupon {
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-decoration: none;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    background: #fff8f6;
    border: 1px solid rgba(209,104,79,0.08);
}

.tw-ai-coupon__info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.tw-ai-coupon__name {
    font-size: 0.95rem;
    font-weight: 800;
    color: #222;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tw-ai-coupon__description {
    font-size: 0.82rem;
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.tw-ai-form {
    display: flex;
    gap: 10px;
    padding: 16px;
    background: #fff;
    border-top: 1px solid rgba(0,0,0,.06);
}

.tw-ai-input {
    flex: 1;
    min-width: 0;
    border: 1px solid rgba(209, 104, 79, 0.3);
    border-radius: 999px;
    padding: 12px 16px;
    font-size: 0.95rem;
    outline: none;
}

.tw-ai-submit {
    background: #d1684f !important;
    border: none;
    border-radius: 999px;
    color: #fff;
    padding: 12px 18px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
    white-space: nowrap;
}

.tw-ai-loading {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    font-size: 0.92rem;
    color: #999;
}

.tw-ai-dot {
    width: 8px;
    height: 8px;
    background: #d1684f;
    border-radius: 50%;
    opacity: 0.25;
    animation: tw-ai-dot 1s infinite ease-in-out;
}

.tw-ai-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.tw-ai-dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes tw-ai-dot {
    0%, 100% { opacity: 0.25; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(-4px); }
}

/* 手機：
 * - 輸入框 16px：iOS Safari 遇到小於 16px 的輸入框會在聚焦時自動放大畫面，送信按鈕會被推出畫面。
 * - 視窗高度跟著可視範圍走（--tw-ai-vv / --tw-ai-kb 由 assistant.js 依 visualViewport 更新），
 *   鍵盤打開時整個視窗縮到鍵盤上方，不會被蓋住。 */
@media (max-width: 767px) {
    #tw-ai-assistant-root {
        bottom: calc(12px + var(--tw-ai-kb, 0px));
    }

    .tw-ai-panel {
        max-height: min(520px, calc(100vh - 36px));
        max-height: min(520px, calc(var(--tw-ai-vv, 100dvh) - 36px));
    }

    .tw-ai-input {
        font-size: 16px;
    }
}
