/* Corner messenger. Kept in its own file so app.css stays untouched and removing the
   <link> removes the whole feature. */
.mtv-chatwidget {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 90;
  font-family: var(--mtv-font-ui);
}

.mtv-chatwidget__bubble {
  position: relative;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  color: #fff;
  background: linear-gradient(140deg, #004574, #d81e5b);
  box-shadow: 0 18px 36px -14px rgba(9, 34, 56, .55), inset 0 1px 0 rgba(255, 255, 255, .28);
  cursor: pointer;
  transition: transform .18s var(--mtv-ease, ease), box-shadow .18s var(--mtv-ease, ease);
}

.mtv-chatwidget__bubble:hover { transform: translateY(-2px); }
.mtv-chatwidget__bubble:active { transform: scale(.95); }
.mtv-chatwidget__bubble:focus-visible { outline: 2px solid rgba(216, 30, 91, .65); outline-offset: 3px; }

.mtv-chatwidget__dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #ff2f6d;
  border: 2px solid #fff;
}

.mtv-chatwidget__panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  display: flex;
  flex-direction: column;
  width: 360px;
  max-height: min(560px, calc(100vh - 140px));
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, .85);
  background: rgba(255, 255, 255, .93);
  -webkit-backdrop-filter: blur(26px) saturate(170%);
  backdrop-filter: blur(26px) saturate(170%);
  box-shadow: 0 28px 60px -24px rgba(9, 34, 56, .5);
  overflow: hidden;
}

.mtv-chatwidget__panel[hidden],
.mtv-chatwidget__form[hidden],
.mtv-chatwidget__back[hidden],
.mtv-chatwidget__sub[hidden],
.mtv-chatwidget__dot[hidden] { display: none !important; }

.mtv-chatwidget__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(0, 69, 116, .1);
}

.mtv-chatwidget__heading { min-width: 0; flex: 1; }
.mtv-chatwidget__title { margin: 0; font-size: 15px; font-weight: 800; color: var(--mtv-navy); }
.mtv-chatwidget__sub { margin: 1px 0 0; font-size: 11px; color: rgba(0, 69, 116, .55); }

.mtv-chatwidget__back {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: rgba(0, 69, 116, .07);
  color: var(--mtv-navy);
  cursor: pointer;
  flex: none;
}

.mtv-chatwidget__back svg { transform: rotate(180deg); }

.mtv-chatwidget__all {
  margin-left: auto;
  font-size: 12px;
  font-weight: 700;
  color: var(--mtv-magenta);
  text-decoration: none;
  white-space: nowrap;
  flex: none;
}

.mtv-chatwidget__body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mtv-chatwidget__note {
  margin: 0;
  padding: 26px 14px;
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
  color: rgba(0, 69, 116, .6);
}

.mtv-chatwidget__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.mtv-chatwidget__item:hover { background: rgba(0, 69, 116, .06); }
.mtv-chatwidget__item:focus-visible { outline: 2px solid rgba(216, 30, 91, .55); outline-offset: -2px; }

.mtv-chatwidget__avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex: none;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  background: linear-gradient(140deg, #004574, #d81e5b);
}

.mtv-chatwidget__meta { flex: 1; min-width: 0; }

.mtv-chatwidget__name {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--mtv-navy);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mtv-chatwidget__preview {
  display: block;
  font-size: 12px;
  color: rgba(0, 69, 116, .58);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mtv-chatwidget__side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  flex: none;
}

.mtv-chatwidget__time { font-size: 10.5px; color: rgba(0, 69, 116, .45); white-space: nowrap; }

.mtv-chatwidget__unread {
  min-width: 19px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--mtv-magenta);
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  text-align: center;
}

.mtv-chatwidget__msg {
  max-width: 84%;
  padding: 8px 11px;
  border-radius: 14px;
  background: rgba(0, 69, 116, .08);
  color: var(--mtv-navy);
  font-size: 13px;
  line-height: 1.42;
  overflow-wrap: anywhere;
  align-self: flex-start;
}

.mtv-chatwidget__msg.is-mine {
  align-self: flex-end;
  background: linear-gradient(140deg, #004574, #d81e5b);
  color: #fff;
}

.mtv-chatwidget__form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid rgba(0, 69, 116, .1);
}

.mtv-chatwidget__form input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid rgba(0, 69, 116, .16);
  border-radius: 999px;
  background: #fff;
  color: var(--mtv-navy);
  font: 500 13px/1.3 var(--mtv-font-ui);
}

.mtv-chatwidget__form input:focus { outline: 2px solid rgba(216, 30, 91, .35); outline-offset: 1px; }

.mtv-chatwidget__send {
  border: 0;
  border-radius: 999px;
  padding: 0 16px;
  background: linear-gradient(140deg, #004574, #d81e5b);
  color: #fff;
  font: 700 13px/1 var(--mtv-font-ui);
  cursor: pointer;
}

.mtv-chatwidget__send:disabled { opacity: .55; cursor: default; }

/* Dark theme: the panel gets its own ink, because --mtv-navy is light text there. */
:root[data-theme="dark"] .mtv-chatwidget__panel {
  border-color: rgba(255, 255, 255, .14);
  background: rgba(13, 24, 36, .95);
  box-shadow: 0 28px 60px -24px rgba(0, 0, 0, .75);
}

:root[data-theme="dark"] .mtv-chatwidget__head,
:root[data-theme="dark"] .mtv-chatwidget__form { border-color: rgba(255, 255, 255, .12); }

:root[data-theme="dark"] .mtv-chatwidget__title,
:root[data-theme="dark"] .mtv-chatwidget__name,
:root[data-theme="dark"] .mtv-chatwidget__msg { color: #E9F2FA; }

:root[data-theme="dark"] .mtv-chatwidget__sub,
:root[data-theme="dark"] .mtv-chatwidget__preview,
:root[data-theme="dark"] .mtv-chatwidget__note { color: rgba(206, 223, 238, .62); }

:root[data-theme="dark"] .mtv-chatwidget__time { color: rgba(206, 223, 238, .45); }
:root[data-theme="dark"] .mtv-chatwidget__back { background: rgba(255, 255, 255, .09); color: #E9F2FA; }
:root[data-theme="dark"] .mtv-chatwidget__item:hover { background: rgba(255, 255, 255, .07); }
:root[data-theme="dark"] .mtv-chatwidget__msg { background: rgba(255, 255, 255, .09); }
:root[data-theme="dark"] .mtv-chatwidget__msg.is-mine { background: linear-gradient(140deg, #004574, #d81e5b); color: #fff; }
:root[data-theme="dark"] .mtv-chatwidget__all { color: #FF87AC; }

:root[data-theme="dark"] .mtv-chatwidget__form input {
  border-color: rgba(255, 255, 255, .16);
  background: rgba(255, 255, 255, .07);
  color: #E9F2FA;
}

:root[data-theme="dark"] .mtv-chatwidget__form input::placeholder { color: rgba(206, 223, 238, .5); }
:root[data-theme="dark"] .mtv-chatwidget__dot { border-color: #0d1824; }

@media (max-width: 820px) {
  /* Clear of the floating navigation dock. */
  .mtv-chatwidget {
    right: 14px;
    bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  }

  .mtv-chatwidget__panel {
    width: min(calc(100vw - 28px), 380px);
    max-height: min(62vh, 520px);
  }
}
