#churchhome-ai.chai,
#churchhome-ai.chai * { box-sizing: border-box; }

#churchhome-ai.chai {
    --chai-main: #173f35;
    --chai-main-dark: #0f3028;
    --chai-point: #d9b875;
    --chai-text: #1f2926;
    --chai-muted: #708079;
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 99990;
    font-family: Pretendard, "Noto Sans KR", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--chai-text);
}

.chai-launcher {
    min-width: 148px;
    height: 58px;
    padding: 0 21px 0 17px;
    border: 0;
    border-radius: 29px;
    background: var(--chai-main);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.03em;
    box-shadow: 0 12px 35px rgba(8, 37, 29, .26);
    cursor: pointer;
    transition: transform .2s ease, background .2s ease, box-shadow .2s ease;
}
.chai-launcher:hover { transform: translateY(-2px); background: var(--chai-main-dark); box-shadow: 0 15px 38px rgba(8, 37, 29, .32); }
.chai-launcher-icon { display: inline-flex; }
.chai.is-open .chai-launcher { opacity: 0; pointer-events: none; transform: translateY(8px); }

.chai-panel {
    position: absolute;
    right: 0;
    bottom: 0;
    width: min(390px, calc(100vw - 28px));
    height: min(650px, calc(100vh - 40px));
    border: 1px solid rgba(18, 62, 50, .1);
    border-radius: 22px;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 24px 70px rgba(20, 42, 35, .24);
    display: flex;
    flex-direction: column;
    animation: chaiUp .22s ease both;
}
.chai-panel[hidden] { display: none !important; }
@keyframes chaiUp { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }

.chai-header {
    min-height: 78px;
    padding: 15px 15px 15px 18px;
    background: linear-gradient(135deg, var(--chai-main), var(--chai-main-dark));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.chai-brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.chai-avatar, .chai-message-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border-radius: 50%;
    font-weight: 800;
}
.chai-avatar { width: 43px; height: 43px; background: var(--chai-point); color: #17362e; font-size: 14px; }
.chai-brand strong { display: block; max-width: 255px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 16px; letter-spacing: -.035em; }
.chai-brand span { display: flex; align-items: center; gap: 6px; margin-top: 4px; color: rgba(255,255,255,.72); font-size: 12px; }
.chai-brand span i { width: 7px; height: 7px; border-radius: 50%; background: #8fe2a9; }
.chai-close { width: 38px; height: 38px; border: 0; border-radius: 50%; background: rgba(255,255,255,.1); color: #fff; font-size: 28px; line-height: 1; cursor: pointer; }
.chai-close:hover { background: rgba(255,255,255,.18); }

.chai-messages {
    flex: 1 1 auto;
    min-height: 0;
    padding: 20px 17px 12px;
    overflow-y: auto;
    background: #f6f8f7;
    scrollbar-width: thin;
}
.chai-message { display: flex; align-items: flex-end; gap: 8px; margin: 0 0 14px; }
.chai-message-user { justify-content: flex-end; }
.chai-message-avatar { width: 29px; height: 29px; background: var(--chai-main); color: #fff; font-size: 10px; }
.chai-bubble {
    max-width: 79%;
    padding: 11px 13px;
    border-radius: 15px;
    background: #fff;
    color: #26342f;
    font-size: 14px;
    line-height: 1.65;
    letter-spacing: -.025em;
    white-space: pre-wrap;
    word-break: keep-all;
    overflow-wrap: anywhere;
    box-shadow: 0 3px 12px rgba(23, 63, 53, .06);
}
.chai-message-assistant .chai-bubble { border-bottom-left-radius: 4px; }
.chai-message-user .chai-bubble { background: var(--chai-main); color: #fff; border-bottom-right-radius: 4px; box-shadow: none; }

.chai-typing { display: flex; gap: 4px; align-items: center; min-height: 41px; }
.chai-typing i { width: 6px; height: 6px; border-radius: 50%; background: #91a099; animation: chaiDot 1.1s infinite ease-in-out; }
.chai-typing i:nth-child(2) { animation-delay: .16s; }
.chai-typing i:nth-child(3) { animation-delay: .32s; }
@keyframes chaiDot { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }

.chai-quick {
    flex: 0 0 auto;
    display: flex;
    gap: 7px;
    padding: 10px 14px 9px;
    overflow-x: auto;
    border-top: 1px solid #edf0ee;
    background: #fff;
    scrollbar-width: none;
}
.chai-quick::-webkit-scrollbar { display: none; }
.chai-quick button {
    flex: 0 0 auto;
    height: 32px;
    padding: 0 12px;
    border: 1px solid #d7e0dc;
    border-radius: 16px;
    background: #fff;
    color: #3b514a;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.chai-quick button:hover { border-color: var(--chai-main); color: var(--chai-main); background: #f4f8f6; }
.chai-quick button:disabled { opacity: .45; cursor: default; }

.chai-actions { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 7px; padding: 0 14px 10px; background: #fff; }
.chai-actions a { height: 35px; border-radius: 8px; display: flex; align-items: center; justify-content: center; text-decoration: none; background: #eef4f1; color: var(--chai-main); font-size: 12px; font-weight: 700; }
.chai-actions a:first-child { background: var(--chai-main); color: #fff; }

.chai-form { display: flex; align-items: flex-end; gap: 8px; padding: 11px 12px 10px 15px; border-top: 1px solid #edf0ee; background: #fff; }
.chai-form textarea { flex: 1 1 auto; width: 100%; height: 42px; max-height: 96px; padding: 10px 4px; border: 0; outline: 0; resize: none; background: transparent; color: #21312b; font: inherit; font-size: 14px; line-height: 1.55; }
.chai-form textarea::placeholder { color: #98a39f; }
.chai-form button { flex: 0 0 auto; width: 42px; height: 42px; border: 0; border-radius: 12px; background: var(--chai-main); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.chai-form button:disabled { background: #a8b4af; cursor: default; }
.chai-notice { margin: 0; padding: 0 12px 10px; background: #fff; color: #9aa39f; text-align: center; font-size: 10px; line-height: 1.4; }

@media (max-width: 600px) {
    #churchhome-ai.chai { right: 14px; bottom: 15px; }
    .chai-launcher { min-width: 56px; width: 56px; padding: 0; }
    .chai-launcher-text { display: none; }
    .chai-panel { position: fixed; inset: 10px; width: auto; height: auto; max-height: none; border-radius: 18px; }
    .chai-header { min-height: 72px; }
    .chai-bubble { max-width: 84%; }
}

@media (prefers-reduced-motion: reduce) {
    .chai-panel, .chai-launcher, .chai-typing i { animation: none !important; transition: none !important; }
}
