/* Lucian UX/UI Prompt #028 · MIT License (c) 2026 Seokwoooo · https://lucianlabs.dev/uxui-prompt/#028 */
/* =========================================================================
   Modding Cafe AI — Floating Chatbox V2 (Phase 9)
   Tiêu chuẩn SaaS 2026 (ChatGPT/Claude/Intercom/Crisp/Linear/Notion AI).
   Scoped under .mcbot — không ảnh hưởng layout site (position:fixed, z-index cao).
   ========================================================================= */
.mcbot, .mcbot *, .mcbot *::before, .mcbot *::after { box-sizing: border-box; }
.mcbot {
  /* Bám Website Theme Engine (--site-*). Fallback Carbon Orange khi chưa có SSR. */
  --mcbot-primary: var(--site-primary, #FF6347);
  --mcbot-primary-hover: var(--site-primary-hover, #ff7a5f);
  --mcbot-bg: #0e131a;
  --mcbot-bg-2: #161c25;
  --mcbot-bg-3: #1e2530;
  --mcbot-line: rgba(255,255,255,.08);
  --mcbot-line-strong: rgba(255,255,255,.14);
  --mcbot-text: #e8edf4;
  --mcbot-text-soft: #c4cdd8;
  --mcbot-mute: #8896a4;
  --mcbot-success: #3ddc84;
  --mcbot-warn: #ffc36b;
  --mcbot-danger: #ff7a7a;
  --mcbot-radius: 16px;
  --mcbot-radius-sm: 10px;
  --mcbot-shadow: 0 24px 60px rgba(0,0,0,.55), 0 0 0 1px rgba(var(--site-primary-rgb,255,99,71),.08);
  position: fixed;
  bottom: 88px;
  z-index: 2147483000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--mcbot-text);
}
.mcbot--bottom-right { right: 22px; }
.mcbot--bottom-left  { left: 22px; }

/* Status colour swap */
.mcbot--status-online  { --mcbot-status-color: var(--mcbot-success); --mcbot-status-label: 'Online'; }
.mcbot--status-busy    { --mcbot-status-color: var(--mcbot-warn);    --mcbot-status-label: 'Busy'; }
.mcbot--status-offline { --mcbot-status-color: var(--mcbot-danger);  --mcbot-status-label: 'Offline'; }

@media (max-width: 640px) { .mcbot[data-mobile="0"]  { display: none !important; } }
@media (min-width: 641px) { .mcbot[data-desktop="0"] { display: none !important; } }

/* ---------- Launcher ---------- */
.mcbot-launcher {
  position: relative;
  width: 60px; height: 60px;
  border: none; border-radius: 50%;
  cursor: pointer;
  background: var(--mcbot-primary);
  color: #fff;
  box-shadow: 0 10px 30px rgba(var(--site-primary-rgb,255,99,71),.45), 0 2px 8px rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  transition: transform .18s ease, box-shadow .18s ease, background .18s;
}
.mcbot-launcher:hover { transform: translateY(-2px) scale(1.04); background: var(--mcbot-primary-hover); }
.mcbot-launcher:active { transform: scale(.96); }
.mcbot-launcher svg { width: 27px; height: 27px; }
.mcbot-launcher__close { display: none; }
.mcbot.is-open .mcbot-launcher__icon  { display: none; }
.mcbot.is-open .mcbot-launcher__close { display: block; }
.mcbot.is-open .mcbot-badge { display: none; }
.mcbot-badge {
  position: absolute; top: -3px; right: -3px;
  background: #0f1419; color: var(--mcbot-primary);
  border: 2px solid var(--mcbot-primary);
  font-size: 10px; font-weight: 800; letter-spacing: .04em;
  padding: 1px 5px; border-radius: 999px; line-height: 1.3;
}

/* ---------- Window (sidebar + main) ---------- */
/* CRITICAL: [hidden] must beat `display:flex` below. Browser default
   `[hidden] { display: none }` has lower specificity than `.mcbot-window`,
   so without this rule the JS `els.win.hidden = true` LOOKS closed in
   DevTools but the window stays VISIBLE — exact bug reported on Cốc Cốc/Edge. */
.mcbot-window[hidden] { display: none !important; }
.mcbot-window {
  position: absolute; bottom: 74px;
  width: 720px; max-width: calc(100vw - 32px);
  height: 640px; max-height: calc(100vh - 120px);
  display: flex; flex-direction: row;
  background: linear-gradient(180deg, rgba(22,28,36,.985), rgba(15,20,25,.985));
  backdrop-filter: blur(14px);
  border: 1px solid var(--mcbot-line);
  border-radius: var(--mcbot-radius);
  overflow: hidden;
  box-shadow: var(--mcbot-shadow);
  transform-origin: bottom right;
  animation: mcbot-pop .24s cubic-bezier(.2,.9,.3,1.15);
}
.mcbot--bottom-left  .mcbot-window { left: 0; right: auto; transform-origin: bottom left; }
.mcbot--bottom-right .mcbot-window { right: 0; }
@keyframes mcbot-pop { from { opacity:0; transform: translateY(12px) scale(.97); } to { opacity:1; transform:none; } }
.mcbot-window.is-closing { animation: mcbot-pop-out .18s ease forwards; }
@keyframes mcbot-pop-out { to { opacity:0; transform: translateY(8px) scale(.98); } }

/* ---------- Sidebar (conversations) ---------- */
.mcbot-sidebar {
  width: 240px; flex: none;
  display: flex; flex-direction: column;
  background: rgba(10,14,20,.6);
  border-right: 1px solid var(--mcbot-line);
  transition: transform .22s ease;
}
.mcbot-sidebar.is-collapsed { display: none; }
.mcbot-sidebar__head {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 10px 8px;
}
.mcbot-newchat {
  flex: 1; display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; border-radius: var(--mcbot-radius-sm);
  background: var(--mcbot-primary); color: #fff;
  border: none; font: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: background .15s, transform .1s;
}
.mcbot-newchat:hover { background: var(--mcbot-primary-hover); }
.mcbot-newchat:active { transform: scale(.97); }
.mcbot-newchat svg { width: 16px; height: 16px; }
.mcbot-sidebar__close { display: none; }
.mcbot-sidebar__list {
  flex: 1; overflow-y: auto; padding: 6px 6px 12px;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent;
}
.mcbot-sidebar__list::-webkit-scrollbar { width: 6px; }
.mcbot-sidebar__list::-webkit-scrollbar-thumb { background: rgba(255,255,255,.16); border-radius: 4px; }
.mcbot-conv {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 10px; border-radius: var(--mcbot-radius-sm);
  cursor: pointer; transition: background .12s;
  position: relative; min-width: 0;
}
.mcbot-conv:hover { background: rgba(255,255,255,.05); }
.mcbot-conv.is-active { background: rgba(var(--site-primary-rgb,255,99,71),.14); }
.mcbot-conv__title {
  flex: 1; min-width: 0;
  font-size: 13.5px; line-height: 1.35; color: var(--mcbot-text-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mcbot-conv.is-active .mcbot-conv__title { color: #fff; font-weight: 500; }
.mcbot-conv__actions { display: none; gap: 2px; flex: none; }
.mcbot-conv:hover .mcbot-conv__actions, .mcbot-conv.is-active .mcbot-conv__actions { display: flex; }
.mcbot-conv__btn {
  width: 24px; height: 24px; border: none; background: transparent;
  color: var(--mcbot-mute); border-radius: 6px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.mcbot-conv__btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.mcbot-conv__btn svg { width: 13px; height: 13px; }
.mcbot-sidebar__empty {
  padding: 24px 16px; text-align: center; color: var(--mcbot-mute);
  font-size: 12.5px; line-height: 1.6;
}
.mcbot-sidebar__foot {
  padding: 8px 10px; border-top: 1px solid var(--mcbot-line);
}
.mcbot-link {
  background: none; border: none; color: var(--mcbot-mute);
  font: inherit; font-size: 12px; cursor: pointer; padding: 6px;
  width: 100%; text-align: left; border-radius: 6px;
}
.mcbot-link:hover { color: var(--mcbot-danger); background: rgba(255,122,122,.06); }
.mcbot-sidebar-backdrop { display: none; }

/* ---------- Main column ---------- */
.mcbot-main {
  flex: 1; display: flex; flex-direction: column;
  min-width: 0; position: relative;
}

/* ---------- Header ---------- */
.mcbot-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  background: linear-gradient(135deg, rgba(var(--site-primary-rgb,255,99,71),.16), rgba(var(--site-primary-rgb,255,99,71),.04));
  border-bottom: 1px solid var(--mcbot-line);
}
.mcbot-sidebar-toggle { display: none; }
.mcbot-header__id { display: flex; align-items: center; gap: 11px; min-width: 0; flex: 1; }
.mcbot-avatar {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  background: var(--mcbot-primary); color: #fff;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  position: relative;
}
.mcbot-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mcbot-avatar svg { width: 22px; height: 22px; }
.mcbot-avatar--bot .mcbot-avatar__dot {
  position: absolute; bottom: -2px; right: -2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--mcbot-status-color, var(--mcbot-success));
  border: 2.5px solid var(--mcbot-bg-2);
  box-shadow: 0 0 8px var(--mcbot-status-color, var(--mcbot-success));
}
.mcbot-header__txt { display: flex; flex-direction: column; min-width: 0; }
.mcbot-header__txt strong { font-size: 15.5px; font-weight: 700; letter-spacing: .01em; }
.mcbot-status { font-size: 12px; color: var(--mcbot-mute); display: inline-flex; align-items: center; gap: 6px; margin-top: 1px; }
.mcbot-status__dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--mcbot-status-color, var(--mcbot-success));
  box-shadow: 0 0 6px var(--mcbot-status-color, var(--mcbot-success));
}
.mcbot-header__actions { display: flex; gap: 2px; flex: none; }
.mcbot-iconbtn {
  width: 32px; height: 32px; border-radius: 8px; border: none; cursor: pointer;
  background: transparent; color: var(--mcbot-text-soft);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
  /* Prevent stray overlays from blocking clicks */
  position: relative; z-index: 2;
}
.mcbot-iconbtn:hover { background: rgba(255,255,255,.10); color: #fff; }
.mcbot-iconbtn:active { transform: scale(.94); }
.mcbot-iconbtn svg { width: 17px; height: 17px; pointer-events: none; }
.mcbot-close:hover { background: rgba(var(--site-primary-rgb,255,99,71),.22); color: #fff; }

/* ---------- Messages ---------- */
.mcbot-messages {
  flex: 1; overflow-y: auto; padding: 18px 18px 12px;
  display: flex; flex-direction: column; gap: 16px;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent;
  scroll-behavior: smooth;
}
.mcbot-messages::-webkit-scrollbar { width: 8px; }
.mcbot-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,.16); border-radius: 4px; }

/* Message row: avatar + bubble */
.mcbot-msg {
  display: flex; gap: 10px; max-width: 100%;
  animation: mcbot-msg-in .22s ease;
}
@keyframes mcbot-msg-in { from { opacity:0; transform: translateY(4px); } to { opacity:1; transform:none; } }
.mcbot-msg--bot  { align-self: flex-start; flex-direction: row; }
.mcbot-msg--user { align-self: flex-end;  flex-direction: row-reverse; }
.mcbot-msg__avatar {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: var(--mcbot-bg-3); color: var(--mcbot-text-soft);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  margin-top: 2px;
}
.mcbot-msg--bot  .mcbot-msg__avatar { background: var(--mcbot-primary); color: #fff; }
.mcbot-msg__avatar img { width: 100%; height: 100%; object-fit: cover; }
.mcbot-msg__avatar svg { width: 16px; height: 16px; }

.mcbot-msg__body { min-width: 0; max-width: calc(100% - 42px); display:flex; flex-direction:column; gap:6px; }
.mcbot-msg__bubble {
  padding: 12px 15px;
  font-size: 15px; line-height: 1.7;
  word-wrap: break-word; overflow-wrap: anywhere;
  border-radius: 14px;
}
.mcbot-msg--bot .mcbot-msg__bubble {
  background: var(--mcbot-bg-2);
  border: 1px solid var(--mcbot-line);
  color: var(--mcbot-text);
  border-bottom-left-radius: 4px;
}
.mcbot-msg--user .mcbot-msg__bubble {
  background: var(--mcbot-primary); color: #fff;
  border-bottom-right-radius: 4px;
  font-size: 14.5px; line-height: 1.55;
}

/* Markdown styling inside bubbles */
.mcbot-md > *:first-child { margin-top: 0; }
.mcbot-md > *:last-child  { margin-bottom: 0; }
.mcbot-md p { margin: 0 0 12px; line-height: 1.75; font-size: 15px; }
.mcbot-md strong { font-weight: 700; color: #fff; }
.mcbot-md em { font-style: italic; }
.mcbot-md del { text-decoration: line-through; opacity: .7; }
.mcbot-md h1, .mcbot-md h2, .mcbot-md h3, .mcbot-md h4 {
  margin: 18px 0 10px; line-height: 1.3; color: #fff; font-weight: 700;
}
.mcbot-md h1 { font-size: 19px; }
.mcbot-md h2 { font-size: 17px; border-bottom: 1px solid var(--mcbot-line); padding-bottom: 6px; }
.mcbot-md h3 { font-size: 15.5px; color: var(--mcbot-primary); }
.mcbot-md h4 { font-size: 14.5px; color: var(--mcbot-text-soft); text-transform: uppercase; letter-spacing: .04em; }
.mcbot-md ul, .mcbot-md ol { margin: 4px 0 12px; padding-left: 22px; }
.mcbot-md li { margin: 4px 0; line-height: 1.7; }
.mcbot-md ul { list-style: none; padding-left: 4px; }
.mcbot-md ul > li { position: relative; padding-left: 18px; }
.mcbot-md ul > li::before {
  content: ''; position: absolute; left: 4px; top: .65em;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--mcbot-primary);
}
.mcbot-md ol { list-style: decimal; }
.mcbot-md hr { border: 0; border-top: 1px solid var(--mcbot-line); margin: 16px 0; }
.mcbot-md blockquote {
  margin: 10px 0 14px; padding: 8px 14px;
  border-left: 3px solid var(--mcbot-primary);
  background: rgba(var(--site-primary-rgb,255,99,71),.06);
  color: var(--mcbot-text-soft);
  border-radius: 0 8px 8px 0;
}
.mcbot-md a {
  color: var(--mcbot-primary); text-decoration: underline; text-underline-offset: 2px;
  word-break: break-word;
}
.mcbot-md a:hover { color: var(--mcbot-primary-hover); }
.mcbot-md .md-inline-code {
  background: rgba(255,255,255,.07);
  border: 1px solid var(--mcbot-line);
  padding: 1px 6px; border-radius: 5px;
  font-family: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px; color: #ffb59b;
}
.mcbot-md .md-code {
  background: #0a0e14; border: 1px solid var(--mcbot-line);
  border-radius: 10px; padding: 12px 14px; margin: 10px 0 14px;
  overflow-x: auto;
  font-family: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px; line-height: 1.6;
  color: #d8e1ec;
  scrollbar-width: thin;
}
.mcbot-md .md-code code { font-family: inherit; }
.mcbot-md .md-table-wrap {
  margin: 10px 0 14px; overflow-x: auto;
  border: 1px solid var(--mcbot-line); border-radius: 10px;
  scrollbar-width: thin;
}
.mcbot-md .md-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.mcbot-md .md-table th, .mcbot-md .md-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--mcbot-line);
  text-align: left;
}
.mcbot-md .md-table th { background: rgba(255,255,255,.04); font-weight: 700; color: #fff; }
.mcbot-md .md-table tr:last-child td { border-bottom: none; }
.mcbot-md .md-table tbody tr:hover { background: rgba(255,255,255,.025); }
.mcbot-msg--user .mcbot-md a, .mcbot-msg--user .mcbot-md strong { color: #fff; }
.mcbot-msg--user .mcbot-md .md-inline-code { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.25); color: #fff; }

/* Sources block */
.mcbot-sources {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed var(--mcbot-line);
  font-size: 13px;
}
.mcbot-sources__title {
  color: var(--mcbot-mute); font-size: 11px;
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; font-weight: 600;
}
.mcbot-sources a, .mcbot-sources span { display: block; color: var(--mcbot-primary); text-decoration: none; padding: 3px 0; line-height: 1.5; }
.mcbot-sources a:hover { text-decoration: underline; }
.mcbot-sources span { color: var(--mcbot-mute); }

/* Action row under AI bubble (copy etc) */
.mcbot-msg__actions { display: flex; gap: 4px; padding-left: 2px; opacity: 0; transition: opacity .18s; }
.mcbot-msg--bot:hover .mcbot-msg__actions { opacity: 1; }
.mcbot-msg__action {
  border: 1px solid var(--mcbot-line); background: rgba(255,255,255,.03);
  color: var(--mcbot-text-soft); font-size: 11.5px;
  padding: 3px 8px; border-radius: 6px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
  font-family: inherit;
}
.mcbot-msg__action:hover { background: rgba(255,255,255,.07); color: #fff; }
.mcbot-msg__action svg { width: 11px; height: 11px; }
.mcbot-msg__action.is-copied { color: var(--mcbot-success); border-color: var(--mcbot-success); }

/* Typing dots */
.mcbot-typing { display: inline-flex; gap: 5px; padding: 12px 14px; }
.mcbot-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--mcbot-mute); animation: mcbot-blink 1.2s infinite both; }
.mcbot-typing i:nth-child(2) { animation-delay: .2s; }
.mcbot-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes mcbot-blink { 0%,80%,100% { opacity: .25; transform: scale(.85); } 40% { opacity: 1; transform: scale(1); } }

/* Streaming caret (when actively streaming) */
.mcbot-md.is-streaming::after {
  content:'▊'; display:inline-block; margin-left:2px;
  color: var(--mcbot-primary); animation: mcbot-blink-caret 1s steps(2) infinite;
}
@keyframes mcbot-blink-caret { 50% { opacity: 0; } }

/* Error message */
.mcbot-error {
  color: var(--mcbot-danger); font-size: 13.5px; line-height: 1.5;
  display: inline-flex; gap: 8px; align-items: flex-start;
}

/* Welcome / suggested chips */
.mcbot-welcome { display: flex; flex-direction: column; gap: 10px; }
.mcbot-suggested { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.mcbot-suggested:empty { display: none; }
.mcbot-chip {
  border: 1px solid rgba(var(--site-primary-rgb,255,99,71),.4);
  background: rgba(var(--site-primary-rgb,255,99,71),.06);
  color: var(--mcbot-text);
  border-radius: 999px; padding: 8px 14px;
  font: inherit; font-size: 13px;
  cursor: pointer; transition: background .15s, transform .1s;
  text-align: left;
}
.mcbot-chip:hover { background: rgba(var(--site-primary-rgb,255,99,71),.18); }
.mcbot-chip:active { transform: scale(.97); }

/* Quick action bar (under input) — display toggle (no half-shown chips) */
.mcbot-quick-actions { display: none; }
.mcbot-quick-actions.is-visible {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 6px 14px 8px;
  animation: mcbot-qa-in .22s ease;
}
@keyframes mcbot-qa-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.mcbot-qa {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--mcbot-bg-3); border: 1px solid var(--mcbot-line);
  color: var(--mcbot-text-soft);
  font: inherit; font-size: 12.5px; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, transform .1s;
}
.mcbot-qa:hover { background: rgba(var(--site-primary-rgb,255,99,71),.15); color: #fff; border-color: rgba(var(--site-primary-rgb,255,99,71),.4); }
.mcbot-qa:active { transform: scale(.97); }
.mcbot-qa__icon { font-size: 14px; }

/* Scroll to bottom button */
.mcbot-scroll-bottom {
  position: absolute; right: 14px; bottom: 130px;
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--mcbot-line); background: var(--mcbot-bg-2); color: var(--mcbot-text);
  cursor: pointer; display:flex; align-items:center; justify-content:center;
  box-shadow: 0 6px 18px rgba(0,0,0,.4);
  transition: opacity .2s, transform .15s;
  z-index: 5;
}
.mcbot-scroll-bottom:hover { background: var(--mcbot-bg-3); transform: translateY(-2px); }
.mcbot-scroll-bottom svg { width: 16px; height: 16px; }
.mcbot-scroll-bottom[hidden] { display: none !important; }

/* ---------- Input ---------- */
.mcbot-input {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px; border-top: 1px solid var(--mcbot-line);
  background: rgba(15,20,25,.7);
}
.mcbot-input textarea {
  flex: 1; resize: none; max-height: 140px;
  background: var(--mcbot-bg-2); color: var(--mcbot-text);
  border: 1px solid var(--mcbot-line); border-radius: 12px;
  padding: 11px 14px; font: inherit; font-size: 14.5px; line-height: 1.45;
  outline: none; transition: border-color .15s, box-shadow .15s;
  /* Hide ugly OS scrollbar — keep scroll behaviour */
  overflow-y: auto;
  scrollbar-width: none;        /* Firefox */
  -ms-overflow-style: none;     /* old Edge / IE */
}
.mcbot-input textarea::-webkit-scrollbar { width: 0; height: 0; display: none; }
.mcbot-input textarea:focus { border-color: var(--mcbot-primary); box-shadow: 0 0 0 3px rgba(var(--site-primary-rgb,255,99,71),.18); }
.mcbot-input textarea::placeholder { color: var(--mcbot-mute); }
.mcbot-send {
  flex: none; width: 44px; height: 44px; border-radius: 12px; border: none; cursor: pointer;
  background: var(--mcbot-primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .15s, background .15s, transform .1s;
}
.mcbot-send:disabled { opacity: .4; cursor: not-allowed; }
.mcbot-send:not(:disabled):hover { background: var(--mcbot-primary-hover); }
.mcbot-send:not(:disabled):active { transform: scale(.92); }
.mcbot-send svg { width: 19px; height: 19px; }
.mcbot-foot { text-align: center; font-size: 10.5px; color: var(--mcbot-mute); padding: 0 0 8px; letter-spacing: .03em; }

/* ============== MOBILE: full-screen, drawer sidebar ============== */
@media (max-width: 760px) {
  .mcbot { bottom: 72px; }
  .mcbot--bottom-right { right: 16px; }
  .mcbot--bottom-left  { left: 16px; }
  .mcbot-window {
    position: fixed; left: 0; right: 0; bottom: 0;
    width: 100vw; max-width: 100vw; height: 90vh; max-height: 90vh;
    border-radius: 18px 18px 0 0;
    border-left: none; border-right: none; border-bottom: none;
  }
  .mcbot--bottom-left .mcbot-window, .mcbot--bottom-right .mcbot-window { left: 0; right: 0; }
  /* Sidebar becomes an overlay drawer */
  .mcbot-sidebar {
    position: absolute; top: 0; left: 0; bottom: 0;
    width: 280px; max-width: 80vw;
    transform: translateX(-100%);
    z-index: 12; background: var(--mcbot-bg);
    box-shadow: 8px 0 24px rgba(0,0,0,.5);
  }
  .mcbot-sidebar.is-open { transform: translateX(0); }
  .mcbot-sidebar.is-collapsed { display: flex; }
  .mcbot-sidebar__close { display: flex; }
  .mcbot-sidebar-toggle { display: flex; }
  .mcbot-sidebar-backdrop {
    display: block; position: absolute; inset: 0;
    background: rgba(0,0,0,.5); z-index: 11;
    opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  .mcbot-sidebar.is-open + .mcbot-sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .mcbot-scroll-bottom { bottom: 150px; }
}

/* Hide sidebar on desktop when explicitly toggled off */
@media (min-width: 761px) {
  .mcbot-sidebar.is-collapsed { display: none; }
  .mcbot-sidebar-toggle { display: none; }
  .mcbot-sidebar.is-collapsed ~ .mcbot-main .mcbot-sidebar-toggle { display: flex; }
}
/* Composer adapted to the existing conversation, tokens and 2,000-character contract. */
.mcbot { --ux-page:#10151c; --ux-surface:#1a222c; --ux-ink:#f3f5f8; --ux-muted:#9ca9b8; --ux-line-2:#35414e; --ux-accent:var(--mcbot-primary); --ux-accent-soft:rgba(255,99,71,.14); --ux-shadow-strong:rgba(0,0,0,.6); --ux-ease:cubic-bezier(.2,.8,.2,1); --ux-spring:cubic-bezier(.2,1.5,.4,1); }
.mcbot .mcbot-window { width:440px; height:620px; max-height:calc(100dvh - 178px); border-radius:20px; background:#10151c; border-color:rgba(255,255,255,.12); }
.mcbot .mcbot-sidebar { display:flex !important; position:absolute; z-index:12; inset:0 auto 0 0; width:280px; max-width:86%; background:#131a22; box-shadow:8px 0 28px rgba(0,0,0,.42); transform:translateX(-100%); visibility:hidden; pointer-events:none; transition:transform .22s ease,visibility .22s; }
.mcbot .mcbot-sidebar.is-open { transform:translateX(0); visibility:visible; pointer-events:auto; }
.mcbot .mcbot-sidebar__close, .mcbot .mcbot-sidebar-toggle { display:flex !important; }
.mcbot .mcbot-sidebar-backdrop { display:block; position:absolute; inset:0; z-index:11; background:rgba(0,0,0,.55); opacity:0; pointer-events:none; transition:opacity .22s; }
.mcbot .mcbot-sidebar.is-open + .mcbot-sidebar-backdrop { opacity:1; pointer-events:auto; }
.mcbot .mcbot-header { min-height:76px; padding:12px 14px; gap:10px; background:#151c24; }
.mcbot .mcbot-header__id { gap:10px; }
.mcbot .mcbot-avatar { width:48px; height:48px; border-radius:14px; background:#10151b; border:1px solid rgba(255,255,255,.13); overflow:visible; }
.mcbot .mcbot-avatar img { object-fit:contain; border-radius:13px; }
.mcbot .mcbot-avatar--bot .mcbot-avatar__dot { bottom:-1px; right:-1px; }
.mcbot .mcbot-header__txt strong { color:#f5f7fa; line-height:1.25; }
.mcbot .mcbot-iconbtn { width:36px; height:36px; }
.mcbot #mcbot-minimize { display:none; }
.mcbot .mcbot-messages { padding:20px 16px 12px; gap:16px; }
.mcbot .mcbot-msg__avatar { width:38px; height:38px; border-radius:12px; background:#10151b; border:1px solid rgba(255,255,255,.12); overflow:hidden; }
.mcbot .mcbot-msg__avatar img { width:100%; height:100%; object-fit:contain; }
.mcbot .mcbot-msg--user .mcbot-msg__avatar { display:none; }
.mcbot .mcbot-msg__bubble { line-height:1.6; }
.mcbot .mcbot-input.u028 { display:block; width:100%; height:auto; padding:10px 14px 8px; border-top:0; background:transparent; }
.mcbot .u028-box { position:relative; padding:14px 14px 12px 16px; border-radius:22px; background:var(--ux-surface); box-shadow:0 0 0 1.5px var(--ux-line-2),0 20px 40px -28px var(--ux-shadow-strong); transition:box-shadow .3s var(--ux-ease); }
.mcbot .u028-box:focus-within { box-shadow:0 0 0 2px var(--ux-accent),0 0 0 6px var(--ux-accent-soft),0 20px 40px -28px var(--ux-shadow-strong); }
.mcbot .mcbot-input .u028-ta { display:block; width:100%; height:24px; min-height:24px; max-height:144px; padding:0; border:0; border-radius:0; outline:0; resize:none; background:none; font:inherit; font-size:15px; line-height:24px; color:var(--ux-ink); overflow:hidden; box-shadow:none; transition:height .25s var(--ux-ease); }
.mcbot .mcbot-input .u028-ta:focus { box-shadow:none; }
.mcbot .u028-ta::placeholder { color:var(--ux-muted); }
.mcbot .u028-foot { display:flex; align-items:center; gap:10px; margin-top:12px; }
.mcbot .u028-hint { font-size:10px; line-height:1.3; color:var(--ux-muted); }
.mcbot .u028-ring { position:relative; width:30px; height:30px; margin-left:auto; flex:none; transition:transform .45s var(--ux-spring); }
.mcbot .u028-ring svg { width:30px; height:30px; transform:rotate(-90deg); fill:none; stroke-width:2; }
.mcbot .u028-track { stroke:var(--ux-line-2); }
.mcbot .u028-progress { stroke:var(--ux-accent); stroke-dasharray:75.4; stroke-dashoffset:0; transition:stroke-dashoffset .25s var(--ux-ease); }
.mcbot .u028-left { position:absolute; inset:0; display:grid; place-items:center; font-size:8px; color:var(--ux-muted); }
.mcbot .u028-sep { width:1px; height:24px; background:var(--ux-line-2); }
.mcbot .u028-send { height:38px; padding:0 16px; border:0; border-radius:12px; background:var(--ux-accent); color:#fff; font:inherit; font-size:14px; font-weight:700; cursor:pointer; transition:opacity .25s var(--ux-ease),transform .4s var(--ux-spring); }
.mcbot .u028-send:disabled { opacity:.42; cursor:not-allowed; }
.mcbot .u028-send:not(:disabled):hover { transform:translateY(-2px); }
.mcbot .u028-send:not(:disabled):active { transform:scale(.96); }
.mcbot :focus-visible { outline:2px solid #ff9a83; outline-offset:3px; }
.mcbot .mcbot-foot { padding:0 0 10px; }
@media (max-width:760px) {
  .mcbot .mcbot-window { width:100vw; max-width:100vw; height: min(700px, 90dvh); max-height:90dvh; border-radius:20px 20px 0 0; }
  .mcbot .u028-hint { font-size:9px; }
}
@media (prefers-reduced-motion:reduce) {
  .mcbot *, .mcbot *::before, .mcbot *::after { animation-duration:.01ms !important; animation-iteration-count:1 !important; transition-duration:.01ms !important; scroll-behavior:auto !important; }
}
.mcbot .u028-send { display:inline-flex; align-items:center; justify-content:center; gap:5px; white-space:nowrap; flex:none; }
.mcbot .mcbot-conv:focus-visible { outline:2px solid #ff9a83; outline-offset:-2px; }

/* Keep the entire widget usable on very short desktop viewports. */
@media (max-height:400px) and (min-width:761px) {
  .mcbot .mcbot-window { position:fixed; bottom:8px; max-height:calc(100dvh - 16px); }
  .mcbot--bottom-right .mcbot-window { right:8px; }
  .mcbot--bottom-left .mcbot-window { left:8px; }
}
.mcbot .mcbot-main { min-height:0; }

/* Keep short user messages at their natural width when the avatar is hidden. */
.mcbot .mcbot-msg--user { max-width: 85%; }
.mcbot .mcbot-msg--user .mcbot-msg__body { max-width: 100%; }
