.mmc-chat-root {
  --mmc-primary: #0c3351;
  --mmc-secondary: #99c340;
  --mmc-white: #fff;
  --mmc-danger: #f06263;
  --mmc-gray: #7c7c7f;
  --mmc-black: #1b1d21;
  --mmc-surface: #f6f7f8;
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 2147483000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--mmc-black);
}

.mmc-chat-root *, .mmc-chat-root *::before, .mmc-chat-root *::after { box-sizing: border-box; }
.mmc-chat-root button, .mmc-chat-root input { font: inherit; }
.mmc-chat-root svg { width: 1em; height: 1em; display: block; }

.mmc-chat-widget { position: relative; }

.mmc-chat-trigger {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--mmc-secondary);
  color: var(--mmc-primary);
  box-shadow: 0 18px 40px rgba(12, 51, 81, .22);
  cursor: pointer;
  transition: transform .25s ease, box-shadow .25s ease;
}
.mmc-chat-trigger:hover { transform: translateY(-3px); box-shadow: 0 22px 50px rgba(12, 51, 81, .28); }
.mmc-chat-trigger:focus-visible { outline: 3px solid color-mix(in srgb, var(--mmc-secondary) 45%, transparent); outline-offset: 3px; }
.mmc-chat-trigger__icon { width: 52px; height: 52px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--mmc-white); }
.mmc-chat-trigger__icon svg { width: 27px; height: 27px; }
.mmc-chat-trigger__text {
  position: absolute;
  right: calc(100% + 10px);
  bottom: 50%;
  width: 190px;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--mmc-secondary);
  color: var(--mmc-primary);
  box-shadow: 0 14px 30px rgba(12, 51, 81, .18);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(50%) translateX(8px);
  transition: opacity .2s ease, visibility .2s ease, transform .2s ease;
}
.mmc-chat-trigger__text strong { font-size: 14px; font-weight: 800; line-height: 1.2; }
.mmc-chat-trigger:hover .mmc-chat-trigger__text,
.mmc-chat-trigger:focus-visible .mmc-chat-trigger__text { opacity: 1; visibility: visible; transform: translateY(50%) translateX(0); }
.mmc-chat-trigger__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--mmc-white);
  border-radius: 999px;
  background: var(--mmc-danger);
  color: var(--mmc-white);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.mmc-chat-panel {
  position: fixed;
  right: 24px;
  bottom: 24px;
  overflow: hidden;
  border: 0;
  border-radius: 20px;
  background: var(--mmc-white);
  box-shadow: 0 18px 45px rgba(12, 51, 81, .24);
  animation: mmc-chat-enter .35s cubic-bezier(.22,1,.36,1);
}
.mmc-chat-panel--identification { width: 380px; }
.mmc-chat-panel--conversation { width: 380px; height: 520px; }
.mmc-chat-panel--state { width: 380px; min-height: 220px; }
.mmc-chat-panel__close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--mmc-gray);
  font-size: 26px;
  line-height: 28px;
  cursor: pointer;
}
.mmc-chat-panel__close:hover { color: var(--mmc-danger); background: rgba(240,98,99,.1); }
.mmc-chat-panel__close--header { top: 20px; right: 16px; color: rgba(255,255,255,.82); }
.mmc-chat-panel__close--header:hover { color: #fff; background: rgba(255,255,255,.12); }

.mmc-chat-state {
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 42px 28px 30px;
  text-align: center;
  color: var(--mmc-primary);
}
.mmc-chat-state strong { margin-top: 14px; font-size: 17px; font-weight: 800; }
.mmc-chat-state small { max-width: 280px; margin-top: 7px; color: var(--mmc-gray); font-size: 13px; line-height: 1.45; }
.mmc-chat-state__retry { margin-top: 18px; padding: 10px 18px; border: 0; border-radius: 999px; background: var(--mmc-primary); color: #fff; font-size: 13px; font-weight: 800; cursor: pointer; }
.mmc-chat-state__icon { width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: color-mix(in srgb, var(--mmc-secondary) 18%, transparent); color: var(--mmc-primary); }
.mmc-chat-state__icon--error { background: rgba(240,98,99,.1); color: var(--mmc-danger); }
.mmc-chat-state__icon svg { width: 24px; height: 24px; }
.mmc-chat-spinner { width: 34px; height: 34px; border: 3px solid rgba(12,51,81,.12); border-top-color: var(--mmc-secondary); border-radius: 50%; animation: mmc-spin .8s linear infinite; }

.mmc-chat-identification { display: flex; flex-direction: column; align-items: center; padding: 34px 28px 26px; background: #fff; }
.mmc-chat-identification__icon { width: 54px; height: 54px; margin-bottom: 14px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: color-mix(in srgb, var(--mmc-secondary) 18%, transparent); color: var(--mmc-primary); }
.mmc-chat-identification__icon svg { width: 25px; height: 25px; }
.mmc-chat-identification__header { width: 100%; margin-bottom: 22px; text-align: center; }
.mmc-chat-identification__header h3 { margin: 0 0 7px; color: var(--mmc-primary); font-size: 18px; line-height: 1.25; font-weight: 800; }
.mmc-chat-identification__header p { max-width: 290px; margin: 0 auto; color: var(--mmc-gray); font-size: 13px; line-height: 1.5; }
.mmc-chat-identification__form { width: 100%; display: flex; flex-direction: column; gap: 16px; }
.mmc-chat-field label { display: block; margin: 0 0 6px 4px; color: var(--mmc-primary); font-size: 12px; font-weight: 700; }
.mmc-chat-field__input { position: relative; width: 100%; }
.mmc-chat-field__input > span { position: absolute; top: 50%; left: 14px; transform: translateY(-50%); color: var(--mmc-gray); pointer-events: none; }
.mmc-chat-field__input > span svg { width: 16px; height: 16px; }
.mmc-chat-field__input input {
  width: 100%; height: 48px; margin: 0; padding: 0 14px 0 40px;
  border: 1px solid rgba(124,124,127,.32); border-radius: 12px; outline: none;
  background: #f8f9fa; color: var(--mmc-black); font-size: 16px; line-height: normal;
}
.mmc-chat-field__input input:focus { border-color: var(--mmc-secondary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--mmc-secondary) 16%, transparent); background: #fff; }
.mmc-chat-field__input input.is-invalid { border-color: var(--mmc-danger); box-shadow: 0 0 0 4px rgba(240,98,99,.12); }
.mmc-chat-field__error { min-height: 0; display: block; margin: 6px 0 0 4px; color: var(--mmc-danger); font-size: 11px; font-weight: 600; }
.mmc-chat-server-error { display: flex; align-items: flex-start; gap: 7px; color: var(--mmc-danger); font-size: 12px; line-height: 1.4; }
.mmc-chat-server-error svg { width: 16px; height: 16px; flex: 0 0 16px; margin-top: 1px; }
.mmc-chat-identification__submit { width: 100%; height: 46px; margin: 2px 0 0; display: flex; align-items: center; justify-content: center; gap: 9px; border: 0; border-radius: 999px; background: var(--mmc-primary); color: #fff; box-shadow: 0 10px 22px rgba(12,51,81,.22); font-size: 13px; font-weight: 800; cursor: pointer; }
.mmc-chat-identification__submit:hover { background: var(--mmc-secondary); color: var(--mmc-primary); }
.mmc-chat-identification__submit svg { width: 16px; height: 16px; }
.mmc-chat-identification__footer { margin-top: 18px; display: flex; align-items: center; justify-content: center; gap: 5px; color: rgba(124,124,127,.82); font-size: 10px; line-height: 1.4; text-align: center; }
.mmc-chat-identification__footer svg { width: 14px; height: 14px; color: var(--mmc-secondary); }

.mmc-chat-container { width: 100%; height: 100%; display: flex; flex-direction: column; background: #fff; }
.mmc-chat-header { height: 72px; flex: 0 0 72px; display: flex; align-items: center; gap: 12px; padding: 0 52px 0 20px; border-bottom: 1px solid rgba(12,51,81,.08); background: var(--mmc-primary); }
.mmc-chat-header__icon { width: 40px; height: 40px; flex: 0 0 40px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--mmc-secondary); color: var(--mmc-primary); }
.mmc-chat-header__icon svg { width: 20px; height: 20px; }
.mmc-chat-header__info { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.mmc-chat-header__info strong { color: #fff; font-size: 15px; font-weight: 800; line-height: 1.3; }
.mmc-chat-connection { display: flex; align-items: center; gap: 6px; margin-top: 2px; color: rgba(255,255,255,.78); font-size: 11px; white-space: nowrap; }
.mmc-chat-connection__dot { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: rgba(255,255,255,.4); }
.mmc-chat-connection__dot.is-connected { background: var(--mmc-secondary); }
.mmc-chat-connection__dot.is-reconnecting { animation: mmc-pulse 1.1s ease-in-out infinite; }
.mmc-chat-feedback { display: flex; align-items: flex-start; gap: 8px; padding: 8px 14px; font-size: 11px; line-height: 1.4; }
.mmc-chat-feedback svg { width: 15px; height: 15px; flex: 0 0 15px; }
.mmc-chat-feedback--error { background: rgba(240,98,99,.1); color: #b33a3b; }

.mmc-chat-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 16px; background: var(--mmc-surface); scroll-behavior: smooth; }
.mmc-chat-messages::-webkit-scrollbar { width: 5px; }
.mmc-chat-messages::-webkit-scrollbar-thumb { border-radius: 999px; background: rgba(124,124,127,.3); }
.mmc-chat-message { display: flex; width: 100%; margin-bottom: 12px; }
.mmc-chat-message--support, .mmc-chat-message--system { justify-content: flex-start; }
.mmc-chat-message--me { justify-content: flex-end; }
.mmc-chat-message__bubble { max-width: 78%; padding: 10px 12px; border-radius: 14px; font-size: 14px; line-height: 1.45; text-align: left; word-break: break-word; box-shadow: 0 2px 6px rgba(12,51,81,.06); }
.mmc-chat-message__bubble > span { display: block; white-space: pre-wrap; }
.mmc-chat-message__bubble small { display: block; margin-top: 4px; font-size: 10px; opacity: .65; text-align: right; }
.mmc-chat-message--support .mmc-chat-message__bubble { border-bottom-left-radius: 4px; background: #fff; color: var(--mmc-black); }
.mmc-chat-message--system .mmc-chat-message__bubble { background: rgba(12,51,81,.07); color: var(--mmc-primary); box-shadow: none; }
.mmc-chat-message--me .mmc-chat-message__bubble { border-bottom-right-radius: 4px; background: var(--mmc-secondary); color: var(--mmc-primary); }
.mmc-chat-message--support { align-items: flex-end; gap: 8px; }
.mmc-chat-message__avatar { width: 30px; height: 30px; flex: 0 0 30px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--mmc-primary); color: #fff; font-size: 10px; font-weight: 800; letter-spacing: .03em; box-shadow: 0 2px 7px rgba(12,51,81,.14); overflow: hidden; }
.mmc-chat-message__avatar img { width: 100%; height: 100%; display: block; object-fit: cover; border-radius: 50%; }
.mmc-chat-message__support-content { max-width: calc(78% - 38px); min-width: 0; }
.mmc-chat-message__sender-name { display: block; margin: 0 0 4px 3px; color: var(--mmc-primary); font-size: 10px; font-weight: 800; line-height: 1.2; }
.mmc-chat-message__support-content .mmc-chat-message__bubble { max-width: 100%; }

.mmc-chat-input { min-height: 68px; flex: 0 0 68px; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid rgba(12,51,81,.08); background: #fff; }
.mmc-chat-input input { flex: 1; min-width: 0; width: auto; height: 44px; margin: 0; padding: 0 15px; border: 1px solid rgba(124,124,127,.3); border-radius: 999px; outline: none; background: var(--mmc-surface); color: var(--mmc-black); font-size: 16px; line-height: normal; }
.mmc-chat-input input:focus { border-color: var(--mmc-secondary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--mmc-secondary) 14%, transparent); }
.mmc-chat-input button { width: 44px; height: 44px; flex: 0 0 44px; display: flex; align-items: center; justify-content: center; padding: 0; border: 0; border-radius: 50%; background: var(--mmc-secondary); color: var(--mmc-primary); cursor: pointer; }
.mmc-chat-input button:hover:not(:disabled) { background: var(--mmc-primary); color: #fff; }
.mmc-chat-input button:disabled { opacity: .45; cursor: default; }
.mmc-chat-input button svg { width: 19px; height: 19px; }
.mmc-chat-input__spinner { width: 17px; height: 17px; border: 2px solid rgba(12,51,81,.22); border-top-color: var(--mmc-primary); border-radius: 50%; animation: mmc-spin .75s linear infinite; }

@keyframes mmc-spin { to { transform: rotate(360deg); } }
@keyframes mmc-pulse { 0%,100% { opacity:.4 } 50% { opacity:1 } }
@keyframes mmc-chat-enter { from { opacity: 0; transform: translateX(calc(100% + 40px)); } to { opacity:1; transform:translateX(0); } }

@media (max-width: 576px) {
  .mmc-chat-root { right: 14px; bottom: max(14px, env(safe-area-inset-bottom)); left: 14px; }
  .mmc-chat-widget { width: 100%; }
  .mmc-chat-trigger { margin-left: auto; }
  .mmc-chat-trigger__text { right: calc(100% + 8px); width: 180px; }
  .mmc-chat-panel { right: 14px; bottom: max(14px, env(safe-area-inset-bottom)); border-radius: 18px; }
  .mmc-chat-panel--identification,
  .mmc-chat-panel--conversation,
  .mmc-chat-panel--state { width: calc(100vw - 28px); max-width: 380px; }
  .mmc-chat-panel--conversation { height: min(620px, calc(100dvh - 28px - env(safe-area-inset-bottom))); }
  .mmc-chat-identification { padding: 32px 22px 24px; }
  .mmc-chat-message__bubble { max-width: 84%; }
  .mmc-chat-message__support-content { max-width: calc(84% - 38px); }
}

@media (max-width: 380px) {
  .mmc-chat-trigger__text { width: 155px; padding: 9px 12px; }
  .mmc-chat-trigger__text strong { font-size: 12px; }
  .mmc-chat-panel--conversation { height: calc(100dvh - 20px - env(safe-area-inset-bottom)); right: 10px; bottom: max(10px, env(safe-area-inset-bottom)); width: calc(100vw - 20px); }
  .mmc-chat-header { padding-left: 16px; }
  .mmc-chat-messages { padding: 14px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .mmc-chat-panel, .mmc-chat-spinner, .mmc-chat-input__spinner, .mmc-chat-connection__dot.is-reconnecting { animation: none !important; }
  .mmc-chat-messages { scroll-behavior: auto; }
}
