/* KYZEN AI widget */
#kzai { --lvl: 0; position: fixed; z-index: 80; bottom: max(16px, env(safe-area-inset-bottom)); inset-inline-end: 16px; font-family: 'Cairo', 'Inter', sans-serif; }
.kzai-fab { display: flex; align-items: center; gap: 10px; border: 0; cursor: pointer; padding: 5px 16px 5px 5px; border-radius: 999px; color: #fff; font: 800 14px 'Cairo', 'Inter', sans-serif;
  background: linear-gradient(135deg, #1667c7, #23b5e8); box-shadow: 0 12px 30px rgba(13, 63, 122, .45), 0 0 0 3px #fff; position: relative; min-height: 56px; }
[dir="rtl"] .kzai-fab, #kzai[dir="rtl"] .kzai-fab { padding: 5px 5px 5px 16px; }
.kzai-fab img { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; border: 2px solid #fff; }
.kzai-fab::before { content: ''; position: absolute; inset: -6px; border-radius: 999px; border: 2px solid #9fdcff; animation: kzai-ping 2.4s ease-out infinite; pointer-events: none; }
.kzai-dot { position: absolute; top: 6px; inset-inline-start: 40px; width: 12px; height: 12px; border-radius: 50%; background: #2ee59d; border: 2px solid #fff; }
#kzai.open .kzai-fab { display: none; }
@keyframes kzai-ping { 0% { transform: scale(1); opacity: .9; } 100% { transform: scale(1.18); opacity: 0; } }
@media (max-width: 520px) { .kzai-fab-txt { display: none; } .kzai-fab, #kzai[dir="rtl"] .kzai-fab { padding: 5px; } }

.kzai-panel { width: min(380px, calc(100vw - 24px)); height: min(600px, calc(100dvh - 32px)); display: flex; flex-direction: column; border-radius: 26px; overflow: hidden;
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 24px 60px rgba(13, 63, 122, .4), 0 0 0 2px #fff, 0 0 0 4px #9fd2ff;
  animation: kzai-in .35s cubic-bezier(.2, .9, .3, 1.2); color: #0c2a4d; }
.kzai-panel[hidden] { display: none; }
@keyframes kzai-in { from { transform: translateY(30px) scale(.9); opacity: 0; } }
html[data-mode="dark"] .kzai-panel { background: rgba(9, 27, 52, .96); color: #e6f2ff; box-shadow: 0 24px 60px rgba(0, 0, 0, .6), 0 0 0 2px #1d3d66; }
.kzai-panel header { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 14px; background: linear-gradient(135deg, #0d3f7a, #1667c7 60%, #23b5e8); color: #fff; }
.kzai-face { position: relative; width: 58px; height: 58px; flex: 0 0 auto; }
.kzai-face img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 2px solid #fff; position: relative; z-index: 1;
  transform: scale(calc(1 + var(--lvl) * .07)); transition: transform .06s linear; }
.kzai-ring { position: absolute; inset: -4px; border-radius: 50%; background: conic-gradient(#ffffff, #9fdcff, #23b5e8, #ffffff); opacity: .35; filter: blur(1px); }
#kzai.speaking .kzai-ring { opacity: 1; inset: calc(-4px - var(--lvl) * 10px); box-shadow: 0 0 calc(10px + var(--lvl) * 30px) rgba(170, 225, 255, .95); animation: kzai-spin 3s linear infinite; }
@keyframes kzai-spin { to { transform: rotate(360deg); } }
.kzai-head { flex: 1; min-width: 0; line-height: 1.2; }
.kzai-head b { display: block; font: 900 17px 'Cinzel', 'Cairo', serif; letter-spacing: .06em; }
.kzai-head small { opacity: .85; }
.kzai-panel header button { width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .16); color: #fff; cursor: pointer; }
.kzai-voice[aria-pressed="false"] { opacity: .6; }
.kzai-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }
.kzai-msg { max-width: 86%; padding: 10px 13px; border-radius: 18px; font-size: 15px; line-height: 1.55; word-wrap: break-word; animation: kzai-msg .25s ease-out; }
@keyframes kzai-msg { from { transform: translateY(8px); opacity: 0; } }
.kzai-msg.bot { align-self: flex-start; background: #eaf6ff; border: 1px solid #c3def5; border-start-start-radius: 6px; }
html[data-mode="dark"] .kzai-msg.bot { background: #123058; border-color: #1d3d66; }
.kzai-msg.user { align-self: flex-end; background: linear-gradient(135deg, #1667c7, #23b5e8); color: #fff; border-start-end-radius: 6px; }
.kzai-msg.typing { display: flex; gap: 5px; padding: 14px 16px; }
.kzai-msg.typing i { width: 8px; height: 8px; border-radius: 50%; background: #1667c7; animation: kzai-dot 1s infinite; }
.kzai-msg.typing i:nth-child(2) { animation-delay: .15s; } .kzai-msg.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes kzai-dot { 50% { transform: translateY(-5px); opacity: .4; } }
.kzai-link { display: inline-block; margin-top: 6px; padding: 6px 12px; border-radius: 999px; background: #1667c7; color: #fff !important; text-decoration: none; font-weight: 800; font-size: 14px; }
.kzai-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 8px; }
.kzai-chips:empty { display: none; }
.kzai-chips button { border: 1px solid #9fd2ff; background: #fff; color: #1667c7; border-radius: 999px; padding: 7px 12px; font: 700 13px 'Cairo', 'Inter', sans-serif; cursor: pointer; min-height: 36px; }
html[data-mode="dark"] .kzai-chips button { background: #0e2546; color: #8fd3ff; border-color: #1d3d66; }
.kzai-form { display: flex; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid #d7ebfb; }
html[data-mode="dark"] .kzai-form { border-color: #1d3d66; }
.kzai-form input { flex: 1; min-width: 0; min-height: 46px; border: 1px solid #c3def5; border-radius: 999px; padding: 0 16px; font: 15px 'Cairo', 'Inter', sans-serif; background: #fff; color: #0c2a4d; outline: none; }
.kzai-form input:focus { border-color: #1667c7; box-shadow: 0 0 0 3px rgba(22, 103, 199, .2); }
.kzai-form button { width: 46px; height: 46px; flex: 0 0 auto; display: grid; place-items: center; border: 0; border-radius: 50%; cursor: pointer; color: #fff; background: linear-gradient(135deg, #1667c7, #23b5e8); }
.kzai-form .kzai-mic { background: #eaf6ff; color: #1667c7; border: 1px solid #9fd2ff; }
#kzai.listening .kzai-mic { background: #e5354f; color: #fff; border-color: #e5354f; animation: kzai-rec 1s ease-in-out infinite; }
@keyframes kzai-rec { 50% { box-shadow: 0 0 0 8px rgba(229, 53, 79, .25); } }
[dir="rtl"] .kzai-send svg { transform: scaleX(-1); }
@media (max-width: 520px) { #kzai.open { inset: auto 8px max(8px, env(safe-area-inset-bottom)) 8px; } .kzai-panel { width: 100%; height: min(78dvh, 640px); } }
@media (prefers-reduced-motion: reduce) { .kzai-fab::before, #kzai.speaking .kzai-ring { animation: none; } }
