/* Maddix Bot pet widget */
.mzpet-root {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 9600;
}

.mzpet-btn {
  position: relative;
  width: 74px;
  height: 74px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: block;
  -webkit-tap-highlight-color: transparent;
}
.mzpet-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 50%; }

.mzpet-svg { width: 100%; height: 100%; display: block; overflow: visible; }

.mzpet-shadow { fill: rgba(0, 0, 0, 0.28); }
html[data-theme="light"] .mzpet-shadow { fill: rgba(120, 70, 30, 0.22); }

.mzpet-body { fill: url(#mzBody); filter: drop-shadow(0 10px 18px rgba(31, 224, 181, 0.35)); }

.mzpet-eye ellipse { fill: #06251f; transform-origin: center; transform-box: fill-box; }
.mzpet-glint { fill: #fff; }

.mzpet-mouth { stroke: #06251f; stroke-width: 4.5; fill: none; stroke-linecap: round; }
.mzpet-cheek { fill: rgba(255, 122, 89, 0.35); }

/* idle float + squash */
.mzpet-btn .mzpet-svg { animation: mz-bob 3.2s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes mz-bob {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  50% { transform: translateY(-7px) scale(0.985, 1.02); }
}

/* blink */
.mzpet-root.blink .mzpet-eye ellipse { transform: scaleY(0.08); }

/* hover excitement */
.mzpet-btn:hover .mzpet-svg { animation: mz-hop 0.6s ease infinite; }
@keyframes mz-hop {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  30% { transform: translateY(-12px) scale(0.96, 1.06); }
  60% { transform: translateY(0) scale(1.04, 0.94); }
}

/* wiggle attention */
.mzpet-btn.wiggle .mzpet-svg { animation: mz-wiggle 1s ease; }
@keyframes mz-wiggle {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-12deg) translateY(-4px); }
  40% { transform: rotate(10deg) translateY(-8px); }
  60% { transform: rotate(-8deg) translateY(-5px); }
  80% { transform: rotate(6deg) translateY(-2px); }
}

/* status dot */
.mzpet-status-dot {
  position: absolute;
  right: 8px;
  bottom: 10px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  border: 2.5px solid var(--bg);
  box-shadow: 0 0 8px var(--accent);
}

/* teaser bubble */
.mzpet-teaser {
  position: absolute;
  left: 84px;
  bottom: 26px;
  white-space: nowrap;
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--text);
  background: var(--card);
  backdrop-filter: blur(8px);
  border: 1px solid var(--stroke);
  border-radius: 14px 14px 14px 4px;
  padding: 8px 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.mzpet-teaser.show { opacity: 1; transform: translateY(0); }

/* ---------- chat panel ---------- */
.mzpet-panel {
  position: fixed;
  left: 16px;
  bottom: 104px;
  width: min(92vw, 372px);
  height: min(72vh, 540px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9650;
  background: var(--card);
  backdrop-filter: blur(14px);
  border: 1px solid var(--stroke);
  border-radius: 20px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(24px) scale(0.96);
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.mzpet-panel.open { opacity: 1; transform: translateY(0) scale(1); }
.mzpet-panel[hidden] { display: none; }

.mzpet-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(31, 224, 181, 0.16), rgba(27, 165, 255, 0.14));
  border-bottom: 1px solid var(--stroke);
}
html[data-theme="light"] .mzpet-head { background: linear-gradient(135deg, rgba(224, 96, 48, 0.14), rgba(48, 144, 192, 0.12)); }

.mzpet-head-avatar {
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.15);
}
.mzpet-head-avatar svg { width: 100%; height: 100%; display: block; animation: mz-bob 3.2s ease-in-out infinite; }

.mzpet-head-info { line-height: 1.25; cursor: default; }
.mzpet-head-info strong { font-size: 0.95rem; color: var(--text); }
.mzpet-head-sub { display: flex; align-items: center; gap: 5px; font-size: 0.72rem; color: var(--muted); }
.mzpet-online { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 6px var(--accent); display: inline-block; }

.mzpet-close {
  margin-inline-start: auto;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.mzpet-close:hover { background: rgba(255, 77, 77, 0.14); color: #ff6b6b; }

/* tabs (AI / contact) */
.mzpet-tabs {
  display: flex;
  gap: 6px;
  padding: 8px 10px 0;
}
.mzpet-tab {
  flex: 1;
  font-family: inherit;
  font-size: 0.78rem;
  padding: 6px 4px;
  border-radius: 10px 10px 0 0;
  border: 1px solid transparent;
  border-bottom: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}
.mzpet-tab span { pointer-events: none; }
.mzpet-tab:hover { color: var(--text); }
.mzpet-tab.active {
  color: var(--accent);
  background: rgba(31, 224, 181, 0.08);
  border-color: var(--stroke);
}
html[data-theme="light"] .mzpet-tab.active { color: #b04a1e; background: rgba(224, 96, 48, 0.07); }
/* konami party mode */
.mzpet-root.party .mzpet-body { animation: mz-bob 0.5s ease-in-out infinite, mz-hop 0.9s ease-in-out infinite; }
.mzpet-root.party .mzpet-face-grad,
.mzpet-root.party svg stop:first-child { animation: hue-spin 2s linear infinite; }
@keyframes hue-spin {
  from { stop-color: #1fe0b5; }
  50% { stop-color: #ff6bd6; }
  to { stop-color: #ffc857; }
}
.mzpet-confetti {
  position: fixed;
  z-index: 9700;
  width: 9px;
  height: 13px;
  border-radius: 3px;
  pointer-events: none;
  animation: mz-fly 1.25s cubic-bezier(0.16, 0.8, 0.4, 1) forwards;
}
@keyframes mz-fly {
  from { transform: translate(0, 0) rotate(0deg); opacity: 1; }
  to { transform: translate(var(--dx), calc(var(--dy) + 240px)) rotate(540deg); opacity: 0; }
}
html[dir="rtl"] .mzpet-tabs { direction: rtl; }

.mzpet-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* contact form */
.mzpet-contact {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 14px 14px;
  overflow-y: auto;
}
.mzpet-contact-hint {
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--muted);
  margin: 0 0 2px;
}
.mzpet-field {
  font-family: inherit;
  font-size: 0.86rem;
  color: var(--text);
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 9px 13px;
  outline: none;
  transition: border-color 0.2s;
  resize: vertical;
}
html[data-theme="light"] .mzpet-field { background: rgba(255, 255, 255, 0.65); }
.mzpet-field::placeholder { color: var(--muted); }
.mzpet-field:focus { border-color: var(--accent); }
.mzpet-area { min-height: 96px; line-height: 1.55; }

.mzpet-send-wide {
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  border: 0;
  border-radius: 12px;
  padding: 11px;
  cursor: pointer;
  color: #04241d;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 14px rgba(31, 224, 181, 0.35);
  transition: transform 0.15s, opacity 0.2s;
}
html[data-theme="light"] .mzpet-send-wide { color: #fff; }
.mzpet-send-wide:hover { transform: translateY(-1px); }
.mzpet-send-wide:disabled { opacity: 0.6; cursor: wait; transform: none; }

.mzpet-contact-ok {
  font-size: 0.84rem;
  text-align: center;
  margin: 0;
  animation: mz-pop 0.25s ease;
}
.mzpet-contact-ok.ok { color: var(--accent); }
.mzpet-contact-ok.err { color: #ff6b6b; }

/* live thread (telegram bridge) */
.mzpet-thread {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 150px;
  overflow-y: auto;
  padding: 2px 14px 0;
}
.mzpet-thread:not(:empty) { margin-bottom: 4px; }
.mzpet-tbubble {
  max-width: 85%;
  font-size: 0.82rem;
  line-height: 1.5;
  padding: 7px 11px;
  border-radius: 12px;
  animation: mz-pop 0.25s ease;
  word-break: break-word;
}
.mzpet-tbubble.visitor {
  align-self: flex-end;
  background: rgba(31, 224, 181, 0.16);
  border: 1px solid rgba(31, 224, 181, 0.25);
  color: var(--text);
  border-bottom-right-radius: 4px;
}
html[data-theme="light"] .mzpet-tbubble.visitor { background: rgba(224, 96, 48, 0.1); border-color: rgba(224, 96, 48, 0.22); }
.mzpet-tbubble.maddix {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--stroke);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

/* messages */
.mzpet-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
}
.mzpet-msg {
  max-width: 82%;
  padding: 9px 13px;
  font-size: 0.88rem;
  line-height: 1.55;
  word-wrap: break-word;
  white-space: pre-wrap;
  border-radius: 16px;
  animation: mz-pop 0.22s ease;
}
@keyframes mz-pop {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.mzpet-msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04241d;
  border-bottom-right-radius: 5px;
  font-weight: 500;
}
html[data-theme="light"] .mzpet-msg-user { color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.15); }
.mzpet-msg-assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--stroke);
  color: var(--text);
  border-bottom-left-radius: 5px;
}
html[data-theme="light"] .mzpet-msg-assistant { background: rgba(255, 255, 255, 0.55); }

/* typing dots */
.mzpet-typing { display: flex; gap: 4px; align-items: center; padding: 13px 15px; }
.mzpet-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted);
  animation: mz-dot 1.2s ease-in-out infinite;
}
.mzpet-typing span:nth-child(2) { animation-delay: 0.15s; }
.mzpet-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes mz-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* suggestion chips */
.mzpet-chips {
  display: flex;
  gap: 6px;
  padding: 0 12px 8px;
  flex-wrap: wrap;
}
.mzpet-chip {
  font-family: inherit;
  font-size: 0.74rem;
  color: var(--accent);
  background: rgba(31, 224, 181, 0.09);
  border: 1px solid rgba(31, 224, 181, 0.35);
  border-radius: 999px;
  padding: 4px 11px;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}
.mzpet-chip:hover { background: rgba(31, 224, 181, 0.2); transform: translateY(-1px); }
html[data-theme="light"] .mzpet-chip { color: #b04a1e; background: rgba(224, 96, 48, 0.08); border-color: rgba(224, 96, 48, 0.35); }
html[data-theme="light"] .mzpet-chip:hover { background: rgba(224, 96, 48, 0.16); }

/* input */
.mzpet-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--stroke);
}
.mzpet-input {
  flex: 1;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--text);
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--stroke);
  border-radius: 999px;
  padding: 9px 16px;
  outline: none;
  transition: border-color 0.2s;
}
html[data-theme="light"] .mzpet-input { background: rgba(255, 255, 255, 0.65); }
.mzpet-input::placeholder { color: var(--muted); }
.mzpet-input:focus { border-color: var(--accent); }

.mzpet-send {
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #04241d;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 12px rgba(31, 224, 181, 0.4);
  transition: transform 0.15s, box-shadow 0.2s;
}
html[data-theme="light"] .mzpet-send { color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.mzpet-send:hover { transform: scale(1.08); }
.mzpet-send:active { transform: scale(0.95); }

/* RTL adjustments */
html[dir="rtl"] .mzpet-teaser { left: auto; right: 84px; border-radius: 14px 14px 4px 14px; }
html[dir="rtl"] .mzpet-msg-user { border-bottom-right-radius: 16px; border-bottom-left-radius: 5px; align-self: flex-start; }
html[dir="rtl"] .mzpet-msg-assistant { border-bottom-left-radius: 16px; border-bottom-right-radius: 5px; align-self: flex-end; }

@media (max-width: 480px) {
  .mzpet-panel { left: 8px; right: 8px; width: auto; bottom: 98px; height: min(68vh, 500px); }
  .mzpet-root { left: 12px; bottom: 12px; }
  .mzpet-btn { width: 64px; height: 64px; }
}