#ai-sidebar-wrap {
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #eee;
}

#ai-sidebar-btn {
  position: fixed;
  top: 50%;
  right: 0;
  z-index: 100000;
  transform: translateY(-50%);
  background: #1a1a2e;
  color: #fff;
  border: none;
  border-radius: 8px 0 0 8px;
  padding: 10px 8px;
  cursor: pointer;
  font-size: 20px;
  box-shadow: -2px 0 8px rgba(0, 0, 0, .3);
  transition: right .3s;
}

#ai-sidebar-btn:hover {
  background: #16213e;
}

#ai-sidebar-panel {
  position: fixed;
  top: 0;
  right: -380px;
  width: 360px;
  height: 100%;
  z-index: 100001;
  background: #1a1a2e;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 20px rgba(0, 0, 0, .5);
  transition: right .3s;
  border-left: 1px solid #333;
}

#ai-sidebar-panel.open {
  right: 0;
}

#ai-sidebar-btn.shifted {
  right: 360px;
}

#ai-sidebar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #16213e;
  border-bottom: 1px solid #333;
  font-weight: 600;
  font-size: 15px;
}

#ai-sidebar-close {
  background: none;
  border: none;
  color: #aaa;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}

#ai-sidebar-close:hover {
  color: #fff;
}

#ai-sidebar-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#ai-sidebar-msgs .msg {
  max-width: 90%;
  padding: 8px 12px;
  border-radius: 8px;
  line-height: 1.45;
}

#ai-sidebar-msgs .msg.user {
  background: #0f3460;
  align-self: flex-end;
  color: #eee;
  white-space: pre-wrap;
}

#ai-sidebar-msgs .msg.assistant {
  background: #2d2d44;
  align-self: flex-start;
  color: #ddd;
}

#ai-sidebar-msgs .msg.assistant p {
  margin: 0 0 6px;
}

#ai-sidebar-msgs .msg.assistant p:last-child {
  margin: 0;
}

#ai-sidebar-msgs .msg.assistant code {
  background: #111;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 13px;
}

#ai-sidebar-msgs .msg.assistant pre {
  margin: 6px 0;
}

#ai-sidebar-msgs .msg.assistant pre code {
  display: block;
  padding: 8px;
  overflow-x: auto;
  background: #0d0d1a;
}

#ai-sidebar-msgs .msg.assistant ul,
#ai-sidebar-msgs .msg.assistant ol {
  padding-left: 18px;
  margin: 4px 0;
}

#ai-sidebar-msgs .msg.assistant blockquote {
  border-left: 3px solid #555;
  margin: 4px 0;
  padding: 2px 10px;
  color: #aaa;
}

#ai-sidebar-msgs .msg.error {
  background: #5c1a1a;
  align-self: flex-start;
  color: #f88;
  white-space: pre-wrap;
}

#ai-sidebar-msgs .msg.loading {
  background: #2d2d44;
  align-self: flex-start;
  color: #888;
  font-style: italic;
  white-space: pre-wrap;
}

#ai-sidebar-foot {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #333;
  background: #16213e;
}

#ai-sidebar-input {
  flex: 1;
  resize: none;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 8px;
  background: #0d1b2a;
  color: #eee;
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#ai-sidebar-input:focus {
  outline: none;
  border-color: #0f3460;
}

#ai-sidebar-send {
  background: #0f3460;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
  font-weight: 600;
}

#ai-sidebar-send:hover {
  background: #1a5276;
}

.katex-display {
  margin: 4px 0;
  text-align: center;
}
