/* Scoped global mascot: no dependency on the current route or inline styles. */
.tl-mascot {
  --mascot-accent: #4338ca;
  --mascot-ink: #1f2937;
  --mascot-muted: #64748b;
  --mascot-line: #e2e8f0;
  position: fixed;
  left: max(10px, env(safe-area-inset-left));
  bottom: max(44px, calc(env(safe-area-inset-bottom) + 44px));
  z-index: 1000;
  color: var(--mascot-ink);
  font: 14px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.tl-mascot [hidden], .tl-mascot[hidden] { display: none !important; }
.tl-mascot *, .tl-mascot *::before, .tl-mascot *::after { box-sizing: border-box; }
.tl-mascot button, .tl-mascot textarea { font: inherit; }
.tl-mascot button { cursor: pointer; }
.tl-mascot button:disabled { cursor: not-allowed; opacity: .5; }
.tl-mascot button:focus-visible, .tl-mascot textarea:focus-visible {
  outline: 3px solid #818cf8;
  outline-offset: 3px;
}
.tl-mascot-launcher {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-right: auto;
  padding: 0;
  border: 1px solid #c7d2fe;
  border-radius: 20px;
  background: #eef2ff;
  box-shadow: 0 4px 16px #1e293b20;
  transition: background .16s ease, transform .16s ease;
}
.tl-mascot-launcher:hover { background: #e0e7ff; transform: translateY(-2px); }
.tl-mascot-robot {
  position: relative;
  display: block;
  width: 34px;
  height: 27px;
  border: 2px solid var(--mascot-accent);
  border-radius: 10px;
  background: #fff;
}
.tl-mascot-antenna {
  position: absolute;
  left: 14px;
  top: -8px;
  width: 2px;
  height: 6px;
  background: var(--mascot-accent);
}
.tl-mascot-antenna::before {
  content: "";
  position: absolute;
  width: 6px;
  height: 6px;
  left: -2px;
  top: -3px;
  border-radius: 50%;
  background: #fb7185;
}
.tl-mascot-eyes::before, .tl-mascot-eyes::after {
  content: "";
  position: absolute;
  top: 7px;
  width: 5px;
  height: 7px;
  border-radius: 3px;
  background: var(--mascot-accent);
}
.tl-mascot-eyes::before { left: 6px; }
.tl-mascot-eyes::after { right: 6px; }
.tl-mascot-smile {
  position: absolute;
  width: 9px;
  height: 5px;
  bottom: 3px;
  left: 11px;
  border-bottom: 2px solid var(--mascot-accent);
  border-radius: 0 0 8px 8px;
}
.tl-mascot-working .tl-mascot-antenna::before { animation: tl-mascot-pulse 1.4s ease-in-out infinite; }
@keyframes tl-mascot-pulse { 50% { opacity: .35; } }
.tl-mascot-panel {
  position: absolute;
  left: 0;
  bottom: 68px;
  display: flex;
  flex-direction: column;
  width: min(420px, calc(100vw - 32px));
  height: min(600px, calc(100dvh - 180px));
  max-height: calc(100vh - 180px);
  overflow: hidden;
  border: 1px solid var(--mascot-line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 12px 44px #0f172a24;
}
.tl-mascot-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-shrink: 0;
  padding: 16px;
  border-bottom: 1px solid var(--mascot-line);
}
.tl-mascot-heading { flex: 1; min-width: 0; }
.tl-mascot-heading h2 { margin: 0; color: var(--mascot-ink); font-size: 16px; line-height: 1.4; font-weight: 650; }
.tl-mascot-heading p { margin: 4px 0 0; color: var(--mascot-muted); font-size: 12px; }
.tl-mascot-close {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  color: var(--mascot-muted);
  background: transparent;
  font-size: 25px !important;
  line-height: 1;
}
.tl-mascot-close:hover { background: #f1f5f9; color: var(--mascot-ink); }
.tl-mascot-history {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
.tl-mascot-history::-webkit-scrollbar { width: 6px; }
.tl-mascot-history::-webkit-scrollbar-thumb { border-radius: 8px; background: #cbd5e1; }
.tl-mascot-greeting { margin: 0 0 16px; font-weight: 600; }
.tl-mascot-message { margin: 0 0 12px; padding: 12px; border-radius: 12px; background: #f8fafc; }
.tl-mascot-user { margin-left: 24px; background: #eef2ff; }
.tl-mascot-role { color: var(--mascot-muted); font-size: 11px; font-weight: 600; }
.tl-mascot-text { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.tl-mascot-tool { margin: 8px 0; padding: 6px 8px; border-left: 2px solid #a5b4fc; color: #475569; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.tl-mascot-meta { margin: 6px 0 0; color: var(--mascot-muted); font-size: 11px; white-space: pre-wrap; overflow-wrap: anywhere; }
.tl-mascot-progress:empty { display: none; }
.tl-mascot-status { flex-shrink: 0; margin: 0; padding: 0 16px; color: var(--mascot-muted); font-size: 12px; }
.tl-mascot-status:empty { display: none; }
.tl-mascot-error { flex-shrink: 0; margin: 8px 16px; color: #b91c1c; font-size: 12px; overflow-wrap: anywhere; }
.tl-mascot-progress .tl-mascot-error { margin: 8px 0; }
.tl-mascot-form { flex-shrink: 0; padding: 12px 16px 16px; border-top: 1px solid var(--mascot-line); }
.tl-mascot-label { display: block; margin-bottom: 6px; color: #475569; font-size: 12px; }
.tl-mascot-input {
  display: block;
  width: 100%;
  min-height: 72px;
  max-height: 130px;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  color: var(--mascot-ink);
  resize: vertical;
}
.tl-mascot-input::placeholder { color: var(--mascot-muted); }
.tl-mascot-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.tl-mascot-actions button { min-height: 36px; padding: 6px 12px; border: 1px solid var(--mascot-line); border-radius: 8px; background: #fff; color: var(--mascot-ink); font-size: 12px; }
.tl-mascot-actions button:hover:not(:disabled) { background: #f1f5f9; }
.tl-mascot-actions .tl-mascot-new { margin-right: auto; padding-right: 0; padding-left: 0; border-color: transparent; color: var(--mascot-muted); }
.tl-mascot-actions .tl-mascot-send { background: var(--mascot-accent); border-color: var(--mascot-accent); color: #fff; }
.tl-mascot-actions .tl-mascot-send:hover:not(:disabled) { background: #3730a3; }
@media (max-width: 480px) {
  .tl-mascot { right: max(12px, env(safe-area-inset-right)); bottom: calc(88px + env(safe-area-inset-bottom)); }
  .tl-mascot-panel { width: calc(100vw - 24px - env(safe-area-inset-right)); height: min(560px, calc(100dvh - 180px - env(safe-area-inset-bottom))); max-height: calc(100dvh - 180px - env(safe-area-inset-bottom)); }
  .tl-mascot-header { padding: 12px; }
  .tl-mascot-history { padding: 12px; }
  .tl-mascot-form { padding: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .tl-mascot-launcher { transition: none; }
  .tl-mascot-working .tl-mascot-antenna::before { animation: none; }
}

.tl-mascot-att-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.tl-mascot-chip { position: relative; width: 52px; height: 52px; border: 1px solid var(--mascot-line); border-radius: 8px; overflow: hidden; display: grid; place-items: center; background: #f8fafc; }
.tl-mascot-chip img { width: 100%; height: 100%; object-fit: cover; }
.tl-mascot-chip-bad { border-color: #dc2626; }
.tl-mascot-chip .tl-mascot-chip-x { position: absolute; top: 1px; right: 1px; width: 18px; height: 18px; min-height: 0; padding: 0; border-radius: 9px; line-height: 16px; background: rgba(15, 23, 42, .75); color: #fff; border: 0; font-size: 13px; }
.tl-mascot-attach { display: inline-grid; place-items: center; min-width: 40px; min-height: 36px; border: 1px solid var(--mascot-line); border-radius: 8px; background: #fff; cursor: pointer; font-size: 16px; }
.tl-mascot-attach:hover { background: #f1f5f9; }
.tl-mascot-file { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }
.tl-mascot-imgs { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.tl-mascot-imgs img { max-width: 120px; max-height: 120px; border-radius: 8px; border: 1px solid var(--mascot-line); object-fit: cover; }

.tl-mascot-text strong, .tl-mascot-list strong { font-weight: 700; }
.tl-mascot-head { margin: 8px 0 2px; }
.tl-mascot-list { margin: 4px 0 6px; padding-left: 20px; }
.tl-mascot-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; background: #eef2f7; border-radius: 4px; padding: 1px 4px; }
.tl-mascot-pre { margin: 6px 0; padding: 8px 10px; background: #0f172a; color: #e2e8f0; border-radius: 8px; overflow-x: auto; font-size: 12px; white-space: pre-wrap; word-break: break-word; }
.tl-mascot-text a, .tl-mascot-list a { color: #4338ca; text-decoration: underline; }

/* Robot nằm ở góc dưới bên trái (trên thanh dự án); sidebar chừa chỗ để không che mục cuối */
.ws-side{padding-bottom:76px!important}
@media (max-width: 700px) { .tl-mascot { bottom: max(88px, calc(env(safe-area-inset-bottom) + 88px)); } }
.hub-side{padding-bottom:76px!important}
