/* ModbusPilot website assistant (assistant.js) */
.mt-assist-launch {
  position: fixed; right: 20px; bottom: 20px; z-index: 900;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 18px 11px 14px; border: 0; border-radius: 999px; cursor: pointer;
  font: 600 14px/1 "Segoe UI", system-ui, -apple-system, sans-serif; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 24px rgba(47, 111, 222, .35);
  transition: transform .15s ease, box-shadow .15s ease;
}
.mt-assist-launch svg { width: 20px; height: 20px; fill: #fff; }
.mt-assist-launch svg circle { fill: var(--accent); }
.mt-assist-launch:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(47, 111, 222, .45); }
.mt-assist-launch:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 3px; }
.mt-assist-launch.open span { display: none; }
.mt-assist-launch.open { padding: 11px; }

.mt-assist-panel {
  position: fixed; right: 20px; bottom: 76px; z-index: 901;
  width: min(390px, calc(100vw - 24px)); height: min(580px, calc(100vh - 110px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 18px 48px rgba(20, 30, 55, .28);
  animation: mt-assist-in .16s ease-out;
}
@keyframes mt-assist-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.mt-assist-head {
  display: flex; align-items: flex-start; gap: 6px; padding: 12px 12px 10px 16px;
  color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.mt-assist-title { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.mt-assist-title strong { font-size: 15px; }
.mt-assist-title small { flex-basis: 100%; opacity: .85; }
.mt-assist-badge {
  padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: rgba(255, 255, 255, .22);
}
.mt-assist-badge.ai { background: #fff; color: var(--accent-2); }
.mt-assist-icon {
  width: 30px; height: 30px; border: 0; border-radius: 8px; cursor: pointer;
  color: #fff; background: rgba(255, 255, 255, .14); font-size: 15px;
}
.mt-assist-icon:hover, .mt-assist-icon:focus-visible { background: rgba(255, 255, 255, .3); outline: none; }

.mt-assist-log { flex: 1; overflow-y: auto; padding: 14px 14px 6px; background: var(--bg); }
.mt-assist-msg { display: flex; flex-direction: column; margin-bottom: 12px; max-width: 92%; }
.mt-assist-msg.user { margin-left: auto; align-items: flex-end; }
.mt-assist-body {
  padding: 9px 12px; border-radius: 12px; line-height: 1.45; overflow-wrap: anywhere;
  background: var(--panel); border: 1px solid var(--border); border-top-left-radius: 4px;
}
.mt-assist-msg.user .mt-assist-body {
  color: #fff; background: var(--accent); border-color: var(--accent);
  border-top-left-radius: 12px; border-top-right-radius: 4px; white-space: pre-wrap;
}
.mt-assist-body p { margin: 0 0 6px; }
.mt-assist-body p:last-child { margin-bottom: 0; }
.mt-assist-body ul { margin: 4px 0 6px; padding-left: 18px; }
.mt-assist-body li { margin-bottom: 3px; }
.mt-assist-body code {
  font-family: var(--mono); font-size: 12.5px; padding: 1px 4px; border-radius: 4px; background: var(--panel-2);
}
.mt-assist-msg.typing .mt-assist-body { color: var(--muted); letter-spacing: 3px; animation: mt-assist-pulse 1s infinite; }
@keyframes mt-assist-pulse { 50% { opacity: .4; } }
.mt-assist-note { margin: 4px 2px 0; font-size: 12px; color: var(--warn); }
.mt-assist-sources { display: flex; flex-wrap: wrap; gap: 4px 6px; margin: 5px 2px 0; font-size: 12px; color: var(--muted); }
.mt-assist-sources a {
  padding: 1px 8px; border-radius: 999px; text-decoration: none;
  border: 1px solid var(--border); background: var(--panel);
}
.mt-assist-sources a:hover { border-color: var(--accent); }

.mt-assist-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px; background: var(--bg); border-top: 1px solid var(--border); }
.mt-assist-chip {
  padding: 5px 10px; border-radius: 999px; cursor: pointer; font: inherit; font-size: 12.5px;
  color: var(--accent); background: var(--panel); border: 1px solid var(--border);
}
.mt-assist-chip:hover, .mt-assist-chip:focus-visible { border-color: var(--accent); outline: none; }

.mt-assist-form { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px; border-top: 1px solid var(--border); }
.mt-assist-form textarea {
  flex: 1; resize: none; min-height: 38px; max-height: 120px; padding: 8px 10px;
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 10px;
}
.mt-assist-form textarea:focus { outline: none; border-color: var(--accent); }
.mt-assist-form .btn { height: 38px; }
.mt-assist-foot { margin: 0; padding: 0 12px 9px; font-size: 11px; color: var(--muted); }

@media (max-width: 640px) {
  .mt-assist-launch { right: 12px; bottom: 12px; }
  .mt-assist-panel { right: 8px; left: 8px; bottom: 66px; width: auto; height: calc(100vh - 90px); }
}
@media (prefers-reduced-motion: reduce) {
  .mt-assist-launch, .mt-assist-panel, .mt-assist-msg.typing .mt-assist-body { transition: none; animation: none; }
}
@media print { .mt-assist-launch, .mt-assist-panel { display: none !important; } }
