/* ==========================================================================
   AI chat widget
   ========================================================================== */

.rk-has-chat .rk-to-top { bottom: 104px; right: 30px; width: 46px; height: 46px; }

.rk-chat-launcher {
	position: fixed; right: 24px; bottom: 24px; z-index: 1500; width: 64px; height: 64px; border-radius: 50%;
	border: 0; cursor: pointer; background: var(--rk-ink); color: var(--rk-lime);
	display: grid; place-items: center; box-shadow: 0 18px 40px -12px rgba(17, 17, 17, .5);
	transition: transform .4s var(--rk-ease), background .3s, color .3s;
}
.rk-scheme-dark .rk-chat-launcher { background: var(--rk-lime); color: var(--rk-ink); }
.rk-chat-launcher:hover { transform: scale(1.08) rotate(-6deg); }
.rk-chat-ico { grid-area: 1 / 1; display: grid; place-items: center; transition: transform .45s var(--rk-ease), opacity .3s; }
.rk-chat-ico-close { opacity: 0; transform: rotate(-90deg) scale(.5); }
.rk-chat-launcher.is-open .rk-chat-ico-open { opacity: 0; transform: rotate(90deg) scale(.5); }
.rk-chat-launcher.is-open .rk-chat-ico-close { opacity: 1; transform: none; }
.rk-chat-ping { position: absolute; top: 4px; right: 4px; width: 14px; height: 14px; border-radius: 50%; background: var(--rk-lime); border: 2px solid var(--rk-ink); }
.rk-chat-ping::after { content: ""; position: absolute; inset: -2px; border-radius: 50%; background: var(--rk-lime); animation: rk-ping 1.8s var(--rk-ease) infinite; }
.rk-scheme-dark .rk-chat-ping { background: var(--rk-ink); border-color: var(--rk-lime); }
.rk-chat-launcher.is-seen .rk-chat-ping { display: none; }
@keyframes rk-ping { 0% { transform: scale(1); opacity: .8; } 100% { transform: scale(2.6); opacity: 0; } }

.rk-chat {
	position: fixed; right: 24px; bottom: 104px; z-index: 1500; width: min(400px, calc(100vw - 32px)); height: min(620px, calc(100vh - 140px));
	display: flex; flex-direction: column; overflow: hidden;
	background: var(--rk-surface); color: var(--rk-muted); border: 1px solid var(--rk-line); border-radius: 26px;
	box-shadow: 0 40px 90px -30px rgba(17, 17, 17, .45);
	opacity: 0; visibility: hidden; transform: translateY(20px) scale(.96); transform-origin: 100% 100%;
	transition: opacity .35s var(--rk-ease), transform .45s var(--rk-ease), visibility 0s .45s;
	font-size: 15px; line-height: 1.55;
}
.rk-chat.is-open { opacity: 1; visibility: visible; transform: none; transition: opacity .35s var(--rk-ease), transform .45s var(--rk-ease); }

.rk-chat-head { display: flex; align-items: center; gap: 12px; padding: 16px 16px 16px 18px; background: var(--rk-ink); color: #fff; }
.rk-chat-avatar { flex: none; width: 42px; height: 42px; border-radius: 50%; background: var(--rk-lime); color: var(--rk-ink); display: grid; place-items: center; font-family: var(--rk-display); font-weight: 800; font-size: 20px; }
.rk-chat-title { flex: 1; min-width: 0; display: grid; }
.rk-chat-title strong { font-family: var(--rk-display); font-size: 17px; letter-spacing: -.01em; color: #fff; }
.rk-chat-title small { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: rgba(255, 255, 255, .65); }
.rk-chat-title small i { width: 7px; height: 7px; border-radius: 50%; background: var(--rk-lime); box-shadow: 0 0 0 3px rgba(216, 251, 60, .25); }
.rk-chat-icon-btn { flex: none; width: 36px; height: 36px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .18); background: none; color: #fff; cursor: pointer; display: grid; place-items: center; transition: background .25s, color .25s; }
.rk-chat-icon-btn:hover { background: var(--rk-lime); color: var(--rk-ink); border-color: var(--rk-lime); }

.rk-chat-body { flex: 1; overflow-y: auto; padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 10px; background: var(--rk-bg); overscroll-behavior: contain; }
.rk-msg { max-width: 86%; padding: 11px 15px; border-radius: 18px; word-wrap: break-word; }
.rk-msg p { margin: 0 0 .5em; }
.rk-msg p:last-child { margin: 0; }
.rk-msg ul { margin: .2em 0 .5em; padding-left: 1.1em; }
.rk-msg ul:last-child { margin-bottom: 0; }
.rk-msg li { margin: .15em 0; }
.rk-msg a { text-decoration: underline; text-underline-offset: 2px; }
.rk-msg-bot { align-self: flex-start; background: var(--rk-surface); color: var(--rk-fg); border: 1px solid var(--rk-line); border-bottom-left-radius: 6px; }
.rk-msg-user { align-self: flex-end; background: var(--rk-lime); color: var(--rk-ink); border-bottom-right-radius: 6px; font-weight: 500; }
.rk-msg-user a { color: var(--rk-ink); }
.rk-msg.is-new { animation: rk-msg-in .45s var(--rk-ease) both; }
@keyframes rk-msg-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }

.rk-typing { display: inline-flex; gap: 5px; padding: 15px 16px; }
.rk-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--rk-muted); animation: rk-dot 1.2s infinite ease-in-out; }
.rk-typing span:nth-child(2) { animation-delay: .15s; }
.rk-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes rk-dot { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-5px); opacity: 1; } }

.rk-chat-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 16px 10px; background: var(--rk-bg); }
.rk-chat-chips[hidden] { display: none; }
.rk-chip-q { border: 1.5px solid var(--rk-fg); background: transparent; color: var(--rk-fg); border-radius: 999px; padding: 7px 14px; font-size: 13.5px; font-weight: 700; cursor: pointer; transition: background .25s, color .25s, border-color .25s; }
.rk-chip-q:hover { background: var(--rk-lime); border-color: var(--rk-lime); color: var(--rk-ink); }

.rk-chat-form { display: flex; align-items: flex-end; gap: 8px; padding: 12px 12px 6px; border-top: 1px solid var(--rk-line); background: var(--rk-surface); }
.rk-chat-form textarea { flex: 1; resize: none; border: 1px solid var(--rk-line); border-radius: 18px; background: var(--rk-bg); color: var(--rk-fg); padding: 11px 14px; font: inherit; line-height: 1.4; max-height: 120px; min-height: 44px; }
.rk-chat-form textarea:focus { outline: none; border-color: var(--rk-fg); box-shadow: 0 0 0 3px rgba(216, 251, 60, .45); }
.rk-chat-send { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--rk-lime); color: var(--rk-ink); cursor: pointer; display: grid; place-items: center; transition: transform .3s var(--rk-ease), background .25s, color .25s; }
.rk-chat-send:hover { background: var(--rk-ink); color: var(--rk-lime); transform: rotate(-45deg); }
.rk-scheme-dark .rk-chat-send:hover { background: #fff; color: var(--rk-ink); }
.rk-chat-send:disabled { opacity: .5; cursor: default; transform: none; }
.rk-chat-note { margin: 0; padding: 2px 16px 10px; font-size: 11.5px; text-align: center; background: var(--rk-surface); color: var(--rk-muted); }

@media (max-width: 520px) {
	.rk-chat { right: 0; bottom: 0; width: 100vw; height: 100dvh; max-height: none; border-radius: 0; border: 0; transform-origin: 50% 100%; }
	.rk-chat-launcher { right: 16px; bottom: 16px; width: 58px; height: 58px; }
	.rk-chat-launcher.is-open { opacity: 0; pointer-events: none; }
	.rk-has-chat .rk-to-top { bottom: 88px; right: 22px; }
	body.rk-chat-open { overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) {
	.rk-chat, .rk-chat-ico, .rk-msg.is-new { transition: none !important; animation: none !important; }
	.rk-chat-ping::after { animation: none; }
}
