/* Byte — coding buddy */
.buddy { position: fixed; right: 22px; bottom: 18px; z-index: 950; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; pointer-events: none; font-family: var(--font-b); }
.buddy > * { pointer-events: auto; }

/* Launcher + robot */
.buddy__launcher { position: relative; width: 92px; height: 100px; padding: 0; border: 0; background: none; cursor: pointer; opacity: 0; transform: translateY(30px) scale(.8); transition: opacity .6s var(--ease), transform .6s var(--ease); }
.buddy.is-ready .buddy__launcher { opacity: 1; transform: none; }
.buddy__launcher:focus-visible { outline: 2px solid var(--cyan); outline-offset: 4px; border-radius: 20px; }
.byte { width: 100%; height: 100%; overflow: visible; }
.byte--big .byte__body-wrap { transform-origin: 60px 120px; animation: byte-float 3.6s ease-in-out infinite; }
.byte--big .byte__shadow { transform-origin: 60px 125px; animation: byte-shadow 3.6s ease-in-out infinite; }
@keyframes byte-float { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-7px) rotate(-1.5deg); } }
@keyframes byte-shadow { 0%, 100% { transform: scaleX(1); opacity: .18; } 50% { transform: scaleX(.75); opacity: .1; } }
.byte__bulb { animation: byte-bulb 2s ease-in-out infinite; }
@keyframes byte-bulb { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
.byte__antenna { transform-origin: 60px 22px; }
.byte__eyes { transition: transform .25s ease-out; }
.byte__eye { transform-box: fill-box; transform-origin: center; transition: transform .12s; }
.buddy.is-blink .byte__eye { transform: scaleY(.1); }
.byte__mouth { transition: d .3s; }
.byte__arm--r, .byte__hand { transform-origin: 86px 96px; }
.byte.is-bounce .byte__body-wrap { animation: byte-bounce .6s var(--ease); }
@keyframes byte-bounce { 0% { transform: translateY(0) scale(1); } 30% { transform: translateY(-14px) scale(1.06, .94); } 60% { transform: translateY(0) scale(.96, 1.04); } 100% { transform: none; } }
.buddy__launcher:hover .byte__antenna { animation: byte-wiggle .5s ease-in-out 2; }
@keyframes byte-wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }

/* Moods */
.buddy[data-mood="waving"] .byte--big .byte__arm--r, .buddy[data-mood="waving"] .byte--big .byte__hand,
.buddy__launcher:hover .byte__arm--r, .buddy__launcher:hover .byte__hand { animation: byte-wave .45s ease-in-out 4 alternate; }
@keyframes byte-wave { from { transform: rotate(0); } to { transform: rotate(-28deg); } }
.buddy[data-mood="happy"] .byte__mouth, .buddy__launcher:hover .byte__mouth { d: path("M50 63q10 10 20 0"); }
.buddy[data-mood="thinking"] .byte__mouth { d: path("M54 67h12"); }
.buddy[data-mood="thinking"] .byte__eyes { transform: translate(3px, -3px) !important; }
.buddy[data-mood="talking"] .byte__mouth { animation: byte-talk .22s ease-in-out infinite alternate; }
@keyframes byte-talk { from { d: path("M53 65q7 3 14 0"); } to { d: path("M53 64q7 8 14 0"); } }
.buddy[data-mood="confused"] .byte__mouth { d: path("M52 67q4-4 8 0t8 0"); }
.buddy.is-open .byte--big .byte__mouth { d: path("M50 63q10 10 20 0"); }

.buddy__badge { position: absolute; top: 14px; right: 6px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--lime); color: #0a0a0b; font: 800 11px/20px var(--font-h); box-shadow: 0 0 0 3px var(--bg); animation: ping 1.8s infinite; }

/* Speech bubble */
.buddy__bubble { position: relative; max-width: 270px; margin-right: 26px; padding: 14px 34px 14px 16px; border-radius: 18px 18px 4px 18px; background: #16161B; border: 1px solid rgba(0, 245, 255, .35); box-shadow: 0 20px 50px -12px rgba(0, 0, 0, .8), 0 0 40px -12px rgba(0, 245, 255, .4); color: var(--text); font-size: 14px; line-height: 1.5; cursor: pointer; animation: bubble-in .5s var(--ease); }
.buddy__bubble[hidden] { display: none; }
.buddy__bubble b { color: var(--cyan); }
.buddy__bubble::after { content: ""; position: absolute; right: -1px; bottom: -9px; width: 16px; height: 10px; background: #16161B; border-right: 1px solid rgba(0, 245, 255, .35); clip-path: polygon(0 0, 100% 0, 100% 100%); }
.buddy__bubble-close { position: absolute; top: 6px; right: 8px; width: 22px; height: 22px; border: 0; border-radius: 6px; background: none; color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer; }
.buddy__bubble-close:hover { color: #fff; background: var(--surface-2); }
@keyframes bubble-in { from { opacity: 0; transform: translateY(10px) scale(.92); transform-origin: 100% 100%; } }

/* Panel */
.buddy__panel { width: min(380px, calc(100vw - 24px)); height: min(560px, calc(100svh - 150px)); display: flex; flex-direction: column; border-radius: 24px; overflow: hidden; background: rgba(14, 14, 18, .94); backdrop-filter: blur(20px) saturate(160%); -webkit-backdrop-filter: blur(20px) saturate(160%); border: 1px solid var(--border-hi); box-shadow: 0 40px 100px -20px rgba(0, 0, 0, .9), 0 0 60px -25px rgba(0, 245, 255, .5); transform-origin: 100% 100%; animation: panel-in .45s var(--ease); }
.buddy__panel[hidden] { display: none; }
@keyframes panel-in { from { opacity: 0; transform: translateY(16px) scale(.94); } }
.buddy__head { display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 16px; border-bottom: 1px solid var(--border); background: linear-gradient(180deg, rgba(0, 245, 255, .07), transparent); }
.buddy__avatar { width: 40px; height: 44px; flex-shrink: 0; }
.buddy__head b { display: block; font: 800 16px/1.1 var(--font-h); }
.buddy__head small { display: flex; align-items: center; gap: 6px; color: var(--muted); font: 500 11px var(--font-m); }
.buddy__head small i { width: 7px; height: 7px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 8px var(--lime); }
.buddy__close { margin-left: auto; width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; transition: color .2s, border-color .2s; }
.buddy__close:hover { color: #fff; border-color: var(--border-hi); }

.buddy__log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; scroll-behavior: smooth; overscroll-behavior: contain; }
.buddy__msg { max-width: 88%; padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.55; animation: msg-in .35s var(--ease); }
@keyframes msg-in { from { opacity: 0; transform: translateY(8px); } }
.buddy__msg--bot { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; color: #E4E5EA; }
.buddy__msg--bot b { color: #fff; }
.buddy__msg--bot ul, .buddy__msg--bot ol { margin: 6px 0 0; padding-left: 18px; }
.buddy__msg--bot li + li { margin-top: 4px; }
.buddy__msg--user { align-self: flex-end; background: var(--cyan); color: #001214; font-weight: 500; border-bottom-right-radius: 4px; }
.buddy__typing { display: flex; gap: 4px; padding: 14px; }
.buddy__typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--cyan); animation: dot 1.2s infinite; }
.buddy__typing i:nth-child(2) { animation-delay: .15s; } .buddy__typing i:nth-child(3) { animation-delay: .3s; }

.buddy__chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 16px 14px; max-height: 45%; overflow-y: auto; border-top: 1px solid var(--border); }
.buddy__chips:empty { display: none; }
.buddy__chip, .buddy__action { padding: 8px 12px; border-radius: 99px; font-size: 13px; font-weight: 500; line-height: 1.2; cursor: pointer; animation: msg-in .35s var(--ease) backwards; transition: background .2s, border-color .2s, color .2s, transform .2s; }
.buddy__chip { border: 1px solid rgba(0, 245, 255, .3); background: rgba(0, 245, 255, .06); color: var(--cyan); }
.buddy__chip:hover { background: rgba(0, 245, 255, .14); transform: translateY(-1px); }
.buddy__action { border: 1px solid var(--border-hi); background: var(--surface-2); color: var(--text); }
.buddy__action:hover { border-color: var(--lime); color: var(--lime); }
.buddy__action.is-primary { background: var(--lime); border-color: var(--lime); color: #0a0a0b; font-weight: 700; }
.buddy__action.is-primary:hover { color: #0a0a0b; box-shadow: 0 6px 20px -6px var(--lime); }
.buddy__chips > :nth-child(2) { animation-delay: .05s; } .buddy__chips > :nth-child(3) { animation-delay: .1s; } .buddy__chips > :nth-child(4) { animation-delay: .15s; } .buddy__chips > :nth-child(5) { animation-delay: .2s; }

.buddy__form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.buddy__form input { flex: 1; min-width: 0; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--border); background: rgba(0, 0, 0, .35); color: var(--text); font: 400 14px var(--font-b); outline: none; transition: border-color .2s; }
.buddy__form input:focus { border-color: var(--cyan); }
.buddy__form input::placeholder { color: #6E6F7A; }
.buddy__form button { width: 42px; flex-shrink: 0; border: 0; border-radius: 12px; background: var(--cyan); color: #001214; cursor: pointer; display: grid; place-items: center; }
.buddy__form button svg { width: 18px; height: 18px; }

.buddy.is-open .buddy__launcher { width: 64px; height: 70px; }

@media (max-width: 600px) {
	.buddy { right: 10px; bottom: 10px; }
	.buddy__launcher { width: 70px; height: 76px; }
	.buddy.is-open .buddy__launcher { display: none; }
	.buddy__panel { height: min(600px, calc(100svh - 24px)); }
	.buddy__bubble { max-width: 230px; margin-right: 14px; font-size: 13px; }
	.buddy__form input { font-size: 16px; } /* no iOS zoom */
}
@media (prefers-reduced-motion: reduce) {
	.byte--big .byte__body-wrap, .byte__bulb, .buddy__badge { animation: none !important; }
}
