/* Misely Tutor widget. Everything is scoped under .mt- and tokens live on .mt-root,
   so it stays safe when embedded in app.misely.com. Green accent (#39b729) on a light
   neutral ground, white cards, navy type — matched to the Misely dashboard. */

.mt-root,
.mt-root * {
  box-sizing: border-box;
}

/* ---------- tokens (light) ---------- */
.mt-root {
  --mt-ground: #f9f9f9;
  --mt-surface: #ffffff;
  --mt-surface-2: #f5f5f5;
  --mt-nav: #222c3c;
  --mt-text: #1d2a44;
  --mt-text-2: #33415c;
  --mt-muted: #6b7280;
  --mt-faint: #9aa1ad;
  --mt-line: #ebebeb;
  --mt-line-strong: #dcdcdc;
  --mt-accent: #39b729;
  --mt-accent-strong: #31a022;
  --mt-accent-text: #1f7d18;
  --mt-accent-tint: #e7f4e4;
  --mt-on-accent: #ffffff;
  --mt-live: #39b729;
  --mt-coral: #e06a6a;
  --mt-user-bubble: #eef0f3;
  --mt-user-text: #2b3a55;
  --mt-shadow: 0 16px 44px -16px rgba(24, 32, 45, 0.24);
  --mt-shadow-sm: 0 1px 3px rgba(24, 32, 45, 0.08), 0 6px 20px -12px rgba(24, 32, 45, 0.14);
  --mt-radius: 16px;
  --mt-radius-msg: 14px;
}
/* ---------- tokens (dark) ---------- */
@media (prefers-color-scheme: dark) {
  .mt-root:not([data-theme='light']) {
    --mt-ground: #141416;
    --mt-surface: #1c1c1f;
    --mt-surface-2: #26262a;
    --mt-nav: #0e0f11;
    --mt-text: #eceef2;
    --mt-text-2: #c6ccd6;
    --mt-muted: #969ba6;
    --mt-faint: #6a6f7a;
    --mt-line: #2c2c30;
    --mt-line-strong: #38383d;
    --mt-accent: #43c132;
    --mt-accent-strong: #55cf45;
    --mt-accent-text: #63c94f;
    --mt-accent-tint: #16240f;
    --mt-on-accent: #ffffff;
    --mt-live: #45c034;
    --mt-coral: #ec8080;
    --mt-user-bubble: #26262a;
    --mt-user-text: #d3d8e0;
    --mt-shadow: 0 20px 56px -18px rgba(0, 0, 0, 0.62);
    --mt-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 22px -14px rgba(0, 0, 0, 0.5);
  }
}

/* ---------- panel ---------- */
.mt-panel {
  display: flex;
  flex-direction: column;
  background: var(--mt-surface);
  color: var(--mt-text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  border: 1px solid var(--mt-line);
  border-radius: var(--mt-radius);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* standalone: centered card on the ground */
.mt-embed-standalone {
  display: flex;
  justify-content: center;
}
.mt-embed-standalone .mt-panel {
  width: min(560px, 100%);
  height: min(680px, 82vh);
  box-shadow: var(--mt-shadow);
}

/* bubble */
.mt-embed-bubble {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483000;
}
.mt-embed-bubble .mt-panel {
  position: fixed;
  right: 20px;
  bottom: 88px;
  width: min(400px, calc(100vw - 40px));
  height: min(620px, calc(100vh - 120px));
  box-shadow: var(--mt-shadow);
}
.mt-launcher {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
/* Lilly's avatar as the bubble */
.mt-launch-pfp {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  overflow: hidden;
  flex: none;
  background: #fff;
  box-shadow:
    0 10px 22px -8px color-mix(in srgb, var(--mt-accent) 50%, transparent),
    0 0 0 3px color-mix(in srgb, var(--mt-accent) 60%, transparent);
}
.mt-launch-pfp svg,
.mt-launch-pfp img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
/* "Ask Lilly" label beneath the avatar */
.mt-launch-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--mt-text);
  white-space: nowrap;
  background: var(--mt-surface);
  border: 1px solid var(--mt-line);
  padding: 3px 11px;
  border-radius: 999px;
  box-shadow: var(--mt-shadow-sm);
}
.mt-hidden {
  display: none !important;
}

/* ---------- header ---------- */
.mt-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--mt-surface);
  border-bottom: 1px solid var(--mt-line);
}
.mt-pfp {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  flex: none;
  background: #fff;
  box-shadow: 0 0 0 2px var(--mt-surface), 0 0 0 3px color-mix(in srgb, var(--mt-accent) 55%, transparent);
}
.mt-pfp svg,
.mt-pfp img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.mt-id {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}
.mt-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--mt-text);
}
.mt-ai-chip {
  font-size: 10.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--mt-accent-text);
  background: var(--mt-accent-tint);
  border: 1px solid color-mix(in srgb, var(--mt-accent) 34%, transparent);
  padding: 1px 7px;
  border-radius: 999px;
}
.mt-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--mt-muted);
}
.mt-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mt-live);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mt-live) 22%, transparent);
}
.mt-dot-listening {
  background: var(--mt-coral);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mt-coral) 22%, transparent);
}
.mt-dot-offline {
  background: var(--mt-faint);
  box-shadow: none;
}
.mt-controls {
  margin-left: auto;
  display: flex;
  gap: 2px;
}
.mt-icon-btn {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--mt-faint);
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.mt-icon-btn:hover {
  background: var(--mt-surface-2);
  color: var(--mt-text);
}
.mt-icon-btn svg {
  width: 16px;
  height: 16px;
}

/* ---------- avatar/face video slot (future live avatar) ---------- */
.mt-face {
  display: none;
  background: #0b1220;
}
.mt-face.mt-face-on {
  display: block;
}
.mt-face video {
  width: 100%;
  display: block;
}

/* ---------- transcript ---------- */
.mt-log {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--mt-surface);
}
.mt-msg.mt-system {
  align-self: center;
  text-align: center;
  max-width: 92%;
  color: var(--mt-muted);
  font-size: 13px;
  background: var(--mt-surface-2);
  border: 1px solid var(--mt-line);
  border-radius: 12px;
  padding: 10px 14px;
}
.mt-msg.mt-system strong {
  color: var(--mt-text);
  font-weight: 650;
}
.mt-msg.mt-error {
  align-self: center;
  text-align: center;
  max-width: 92%;
  color: var(--mt-coral);
  font-size: 13px;
  background: color-mix(in srgb, var(--mt-coral) 12%, var(--mt-surface));
  border: 1px solid color-mix(in srgb, var(--mt-coral) 35%, transparent);
  border-radius: 12px;
  padding: 10px 14px;
}
.mt-row {
  display: flex;
  gap: 9px;
  align-items: flex-end;
  max-width: 87%;
}
.mt-row.mt-tutor {
  align-self: flex-start;
}
.mt-row.mt-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.mt-pfp-sm {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  overflow: hidden;
  flex: none;
  margin-bottom: 2px;
  background: #fff;
  box-shadow: 0 0 0 1.5px var(--mt-surface), 0 0 0 2.5px color-mix(in srgb, var(--mt-accent) 45%, transparent);
}
.mt-pfp-sm svg,
.mt-pfp-sm img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.mt-bubble {
  padding: 10px 13px;
  border-radius: var(--mt-radius-msg);
  font-size: 14.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.mt-tutor .mt-bubble {
  background: var(--mt-surface);
  border: 1px solid var(--mt-line-strong);
  border-bottom-left-radius: 5px;
  color: var(--mt-text-2);
  box-shadow: var(--mt-shadow-sm);
}
.mt-user .mt-bubble {
  background: var(--mt-user-bubble);
  color: var(--mt-user-text);
  border-bottom-right-radius: 5px;
}
.mt-bubble strong {
  font-weight: 650;
  color: var(--mt-text);
}
.mt-typing {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mt-muted);
  animation: mt-blink 1s infinite;
}
@keyframes mt-blink {
  0%,
  100% {
    opacity: 0.2;
  }
  50% {
    opacity: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  .mt-typing {
    animation: none;
    opacity: 0.6;
  }
}

/* ---------- transient status line ---------- */
.mt-statusbar {
  padding: 4px 16px;
  min-height: 12px;
  font-size: 12px;
  color: var(--mt-muted);
  text-align: center;
  background: var(--mt-surface);
}
.mt-statusbar:empty {
  padding: 0;
  min-height: 0;
}

/* ---------- composer ---------- */
.mt-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--mt-line);
  background: var(--mt-surface);
}
.mt-field {
  flex: 1;
  resize: none;
  border: 1px solid var(--mt-line-strong);
  background: var(--mt-surface-2);
  border-radius: 12px;
  padding: 10px 13px;
  font: inherit;
  font-size: 14.5px;
  max-height: 120px;
  min-height: 42px;
  color: var(--mt-text);
}
.mt-field:focus {
  outline: 2px solid var(--mt-accent);
  outline-offset: -1px;
}
.mt-field::placeholder {
  color: var(--mt-faint);
}
.mt-cbtn {
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 12px;
  border: 1px solid var(--mt-line-strong);
  background: var(--mt-surface);
  color: var(--mt-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.mt-cbtn:hover {
  background: var(--mt-surface-2);
  color: var(--mt-text);
}
.mt-cbtn svg {
  width: 19px;
  height: 19px;
}
.mt-cbtn:focus-visible {
  outline: 2px solid var(--mt-accent);
  outline-offset: 2px;
}
.mt-send {
  background: var(--mt-accent);
  border-color: var(--mt-accent);
  color: var(--mt-on-accent);
}
.mt-send:hover {
  background: var(--mt-accent-strong);
  border-color: var(--mt-accent-strong);
  color: var(--mt-on-accent);
}
.mt-convo.mt-convo-on {
  background: var(--mt-accent);
  border-color: var(--mt-accent);
  color: var(--mt-on-accent);
}
.mt-convo.mt-convo-on:hover {
  background: var(--mt-accent-strong);
  border-color: var(--mt-accent-strong);
  color: var(--mt-on-accent);
}
.mt-mic.mt-mic-on {
  background: var(--mt-coral);
  border-color: var(--mt-coral);
  color: #fff;
  position: relative;
}
.mt-mic.mt-mic-on::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 15px;
  border: 2px solid var(--mt-coral);
  opacity: 0;
  animation: mt-pulse 1.6s ease-out infinite;
}
@keyframes mt-pulse {
  0% {
    transform: scale(0.9);
    opacity: 0.5;
  }
  100% {
    transform: scale(1.25);
    opacity: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .mt-mic.mt-mic-on::after {
    animation: none;
    opacity: 0.35;
  }
}
