#assistant-launch {
  position: fixed;
  left: 14px;
  bottom: 38px;
  z-index: 16;
  padding: 3px;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  cursor: pointer;
}
#assistant-launch:hover img { transform: translateY(-2px); }
#assistant-launch img, .assistant-heading img { display: block; object-fit: contain; }

#assistant-panel {
  position: fixed;
  z-index: 17;
  left: 8px;
  bottom: calc(var(--status-height, 40px) + 8px);
  width: min(420px, calc(100% - 16px));
  height: min(540px, calc(100dvh - var(--assistant-top, 42px) - var(--status-height, 40px) - 16px));
  max-width: 100vw;
  max-height: var(--chat-available-height, 100dvh);
  overflow: hidden;
  box-sizing: border-box;
  border-radius: 12px;
  box-shadow: 0 8px 28px #10192288;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  border: 1px solid var(--cad-line);
  border-top-color: #28a5bd;
  background: rgb(36 46 57 / 90%);
  backdrop-filter: blur(6px);
  color: var(--text);
}
body.assistant-open #assistant-launch { visibility: hidden; }

.assistant-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--slate-3);
  border-bottom: 1px solid var(--cad-line);
}
.assistant-heading h2 { flex: 1; margin: 0; }
#assistant-new { margin-left: auto; }
#assistant-close { font-size: 16px; }

#assistant-messages { overflow: auto; overscroll-behavior: contain; padding: 14px 10px; }
.assistant-message {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 14px;
  overflow-wrap: anywhere;
}
.assistant-message[data-role=user] { flex-direction: row-reverse; }
.chat-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 36px;
  height: 36px;
  overflow: hidden;
  border-radius: 50%;
}
.chat-avatar img { display:block; width:100%; height:100%; object-fit:contain; }
.assistant-message[data-role=user] .chat-avatar { background:#295364; color:#e7f7fb; font-weight:600; }
.assistant-message[data-role=user] .chat-avatar img { object-fit:cover; }
.chat-bubble {
  min-width: 0;
  max-width: calc(100% - 46px);
  box-sizing: border-box;
  padding: 9px 12px;
  border-radius: 3px 12px 12px;
  background: var(--slate-3);
  line-height: 1.5;
}
.assistant-message[data-role=user] .chat-bubble { background:#254653; border-radius:12px 3px 12px 12px; }
.assistant-message p { margin: 0; white-space: pre-wrap; }
.assistant-message small { color: var(--muted); }
.chat-bubble > small, .chat-bubble > details, .chat-tools { display:block; margin-top:6px; }
.chat-tools button, .chat-tools a { margin:4px 6px 2px 0; }

.assistant-state {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  color: var(--muted);
}
.assistant-state:has(#assistant-status:not(:empty)) { min-height: 32px; }
.assistant-state [data-error=true] { color: var(--cad-error); }
.assistant-compose { display: grid; min-width: 0; gap: 4px; padding: 6px 10px 7px; border-top: 1px solid var(--cad-line); }
.assistant-compose textarea {
  width: 100%;
  min-height: 40px;
  max-height: 24dvh;
  resize: vertical;
  font: inherit;
  background: var(--slate-1);
  color: var(--text);
  border: 1px solid var(--control-line);
  padding: 6px;
}
.assistant-compose > .assistant-attachments:not([hidden]) { display: flex; align-items: center; gap: 6px; min-width: 0; }
.assistant-attachments button { flex: none; }
#assistant-send { margin-left: auto; }
.assistant-attachments span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.assistant-attachments input { min-width: 0; flex: 1; color: var(--text); background: var(--slate-1); border: 1px solid var(--control-line); padding: 4px; }
#assistant-send:not(:disabled) { background: #28a5bd; color: #111b20; border-color: #28a5bd; }

.assistant-heading{cursor:grab;touch-action:none;user-select:none}
.assistant-heading.dragging{cursor:grabbing}
#assistant-attach{width:32px;height:32px;font-size:22px;line-height:1;padding:0}

.chat-edge { position:absolute; z-index:2; touch-action:none; user-select:none; }
.chat-edge[data-edge="n"], .chat-edge[data-edge="s"] { left:12px; right:12px; height:6px; cursor:ns-resize; }
.chat-edge[data-edge="w"], .chat-edge[data-edge="e"] { top:12px; bottom:12px; width:6px; cursor:ew-resize; }
.chat-edge[data-edge^="n"] { top:0; }
.chat-edge[data-edge^="s"] { bottom:0; }
.chat-edge[data-edge$="w"] { left:0; }
.chat-edge[data-edge$="e"] { right:0; }
.chat-edge[data-edge="nw"], .chat-edge[data-edge="se"] { width:12px; height:12px; cursor:nwse-resize; }
.chat-edge[data-edge="ne"], .chat-edge[data-edge="sw"] { width:12px; height:12px; cursor:nesw-resize; }
.chat-edge[data-edge="se"]::after { content:""; position:absolute; inset:2px; background:repeating-linear-gradient(135deg,transparent 0 2px,var(--muted) 2px 3px); clip-path:polygon(100% 0,100% 100%,0 100%); }
