/* Miradea assistant. Each design sets --chat-* (or inherits its --sc-* tokens). */
.mchat {
  --_bg: var(--chat-bg, var(--sc-surface, #fff));
  --_ink: var(--chat-ink, var(--sc-ink, #1c1c1a));
  --_soft: var(--chat-soft, var(--sc-ink-soft, #5b5a55));
  --_accent: var(--chat-accent, var(--sc-accent, #5f6b2a));
  --_accent-ink: var(--chat-accent-ink, var(--sc-accent-ink, #fff));
  --_line: var(--chat-line, color-mix(in oklab, var(--_ink) 14%, transparent));
  --_user: var(--chat-user, color-mix(in oklab, var(--_accent) 14%, var(--_bg)));
  --_radius: var(--chat-radius, 16px);
  --_font: var(--chat-font, var(--sc-font-text, system-ui, sans-serif));
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 90; font-family: var(--_font); color: var(--_ink);
}
.mchat__launch {
  display: inline-flex; align-items: center; gap: 0.55rem; min-height: 48px; padding: 0 1.1rem 0 0.95rem;
  border: 0; border-radius: var(--chat-launch-radius, 999px); cursor: pointer;
  background: var(--_accent); color: var(--_accent-ink); font: 600 0.95rem/1 var(--_font); letter-spacing: 0.01em;
  box-shadow: 0 6px 18px -6px rgb(0 0 0 / 0.35), 0 2px 4px rgb(0 0 0 / 0.12);
  transition: transform 140ms cubic-bezier(0.23, 1, 0.32, 1), box-shadow 140ms;
}
.mchat__launch:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) { .mchat__launch:hover { transform: translateY(-1px); } }
.mchat__launch:focus-visible, .mchat button:focus-visible, .mchat textarea:focus-visible { outline: 2px solid var(--_accent); outline-offset: 3px; }
.mchat.is-open .mchat__launch { display: none; }
.mchat__panel {
  position: absolute; right: 0; bottom: 0; width: min(400px, calc(100vw - 32px)); height: min(620px, calc(100dvh - 32px));
  display: flex; flex-direction: column; background: var(--_bg); color: var(--_ink);
  border-radius: var(--_radius); border: 1px solid var(--_line); overflow: hidden;
  box-shadow: 0 24px 60px -18px rgb(0 0 0 / 0.45), 0 4px 12px rgb(0 0 0 / 0.12);
  animation: mchat-in 220ms cubic-bezier(0.23, 1, 0.32, 1);
}
.mchat__panel[hidden] { display: none; }
@keyframes mchat-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.mchat__head { display: flex; align-items: flex-start; gap: 0.5rem; padding: 1rem 0.75rem 0.85rem 1.1rem; border-bottom: 1px solid var(--_line); }
.mchat__head > div { flex: 1; min-width: 0; }
.mchat__title { margin: 0; font: 600 1rem/1.2 var(--chat-title-font, var(--_font)); letter-spacing: 0; }
.mchat__sub { margin: 0.2rem 0 0; font-size: 0.8rem; color: var(--_soft); }
.mchat__close, .mchat__reset { border: 0; background: transparent; color: var(--_soft); cursor: pointer; border-radius: 8px; }
.mchat__close { width: 36px; height: 36px; display: grid; place-items: center; }
.mchat__reset { font: 500 0.75rem/1 var(--_font); padding: 0.6rem 0.5rem; text-decoration: underline; text-underline-offset: 3px; }
.mchat__close:hover, .mchat__reset:hover { color: var(--_ink); }
.mchat__log { flex: 1; overflow-y: auto; padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: 0.7rem; overscroll-behavior: contain; }
.mchat__msg { max-width: 88%; font-size: 0.93rem; line-height: 1.5; padding: 0.65rem 0.85rem; border-radius: 14px; overflow-wrap: anywhere; }
.mchat__msg p { margin: 0; }
.mchat__msg p + p, .mchat__msg p + ul, .mchat__msg ul + p { margin-top: 0.45rem; }
.mchat__msg ul { margin: 0.2rem 0 0; padding-left: 1.1rem; }
.mchat__msg li + li { margin-top: 0.2rem; }
.mchat__msg a { color: inherit; text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--_accent); }
.mchat__msg--assistant { align-self: flex-start; background: color-mix(in oklab, var(--_ink) 6%, var(--_bg)); border-bottom-left-radius: 4px; }
.mchat__msg--user { align-self: flex-end; background: var(--_user); border-bottom-right-radius: 4px; }
.mchat__dots { display: inline-flex; gap: 4px; padding: 0.2rem 0; }
.mchat__dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--_soft); animation: mchat-dot 1s infinite ease-in-out; }
.mchat__dots i:nth-child(2) { animation-delay: 0.15s; } .mchat__dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes mchat-dot { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.mchat__chips { display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0 1.1rem 0.6rem; }
.mchat__chips:empty { display: none; }
.mchat__chips button { border: 1px solid var(--_line); background: transparent; color: var(--_ink); border-radius: 999px; padding: 0.45rem 0.75rem; font: 500 0.8rem/1.2 var(--_font); cursor: pointer; text-align: left; }
.mchat__chips button:hover { border-color: var(--_accent); }
.mchat__form { display: flex; align-items: flex-end; gap: 0.5rem; padding: 0.7rem 0.75rem 0.75rem 1.1rem; border-top: 1px solid var(--_line); }
.mchat__form textarea { flex: 1; resize: none; border: 0; background: transparent; color: var(--_ink); font: 400 0.95rem/1.45 var(--_font); padding: 0.55rem 0; max-height: 120px; caret-color: var(--_accent); }
.mchat__form textarea::placeholder { color: var(--_soft); }
.mchat__form textarea:focus { outline: none; }
.mchat__form button { width: 42px; height: 42px; flex: none; border: 0; border-radius: 12px; background: var(--_accent); color: var(--_accent-ink); display: grid; place-items: center; cursor: pointer; }
.mchat__form.is-busy button { opacity: 0.5; pointer-events: none; }
.mchat__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 520px) {
  .mchat__launch span { display: none; }
  .mchat__launch { width: 52px; height: 52px; padding: 0; justify-content: center; }
  .mchat.is-open { left: 8px; right: 8px; bottom: 8px; }
  .mchat__panel { width: auto; left: 0; right: 0; height: calc(100dvh - 16px); }
}
@media (prefers-reduced-motion: reduce) { .mchat__panel { animation: none; } .mchat__dots i { animation: none; opacity: 0.6; } }
@media print { .mchat { display: none; } }
