#tool-body {
  --primary: #16baaa;
  --primary-light: #e8f8f7;
  --card-bg: #fff;
  --border-color: #e8e8e8;
  --text-color: #333;
  --text-muted: #999;
  --msg-send-bg: #e8f8f7;
  --msg-send-color: #0d8a82;
  --msg-recv-bg: #eef4ff;
  --msg-recv-color: #2563eb;
  --msg-sys-bg: #f5f5f5;
  --msg-sys-color: #888;
  --log-bg: #f9f9f9;
  --status-dot-off: #ccc;
  --input-bg: #fff;
}
.theme-dark-mode #tool-body {
  --card-bg: #2d2d2d;
  --border-color: #444;
  --text-color: #eee;
  --text-muted: #888;
  --msg-send-bg: #1a3a38;
  --msg-send-color: #4ecdc4;
  --msg-recv-bg: #1a2540;
  --msg-recv-color: #7ba7f7;
  --msg-sys-bg: #383838;
  --msg-sys-color: #aaa;
  --log-bg: #252525;
  --status-dot-off: #555;
  --input-bg: #383838;
}

#tool-body * { box-sizing: border-box; }

#tool-body .ws-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 14px;
}

/* 连接栏 */
#tool-body .conn-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
#tool-body .conn-input-wrap {
  flex: 1;
  min-width: 200px;
  position: relative;
}
#tool-body .conn-input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--input-bg);
  color: var(--text-color);
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
}
#tool-body .conn-input:focus { border-color: var(--primary); }

#tool-body .status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--status-dot-off);
  display: inline-block;
  margin-right: 6px;
  flex-shrink: 0;
  transition: background .3s;
}
#tool-body .status-dot.connecting { background: #f5a623; animation: ws-blink .7s infinite; }
#tool-body .status-dot.connected  { background: #5cb85c; }
#tool-body .status-dot.error      { background: #e05454; }
@keyframes ws-blink { 0%,100%{opacity:1} 50%{opacity:.3} }

#tool-body .status-text {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}
#tool-body .status-text.connected  { color: #5cb85c; }
#tool-body .status-text.error      { color: #e05454; }

/* 日志区 */
#tool-body .log-area {
  background: var(--log-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  height: 340px;
  overflow-y: auto;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.7;
}
#tool-body .log-empty {
  color: var(--text-muted);
  text-align: center;
  padding-top: 120px;
  font-size: 14px;
}
#tool-body .log-item {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
  align-items: flex-start;
}
#tool-body .log-time {
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
  padding-top: 3px;
  flex-shrink: 0;
}
#tool-body .log-badge {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 20px;
  font-weight: bold;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}
#tool-body .log-badge.send { background: var(--msg-send-bg); color: var(--msg-send-color); }
#tool-body .log-badge.recv { background: var(--msg-recv-bg); color: var(--msg-recv-color); }
#tool-body .log-badge.sys  { background: var(--msg-sys-bg);  color: var(--msg-sys-color);  }
#tool-body .log-content {
  color: var(--text-color);
  word-break: break-all;
  white-space: pre-wrap;
  flex: 1;
  margin-top: 2px;
}
#tool-body .log-content.send { color: var(--msg-send-color); }
#tool-body .log-content.recv { color: var(--msg-recv-color); }
#tool-body .log-content.sys  { color: var(--msg-sys-color);  }

/* 发送区 */
#tool-body .send-textarea {
  width: 100%;
  min-height: 90px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text-color);
  font-size: 14px;
  resize: vertical;
  outline: none;
  transition: border-color .2s;
  font-family: 'Consolas', monospace;
}
#tool-body .send-textarea:focus { border-color: var(--primary); }
#tool-body .ws-card .layui-input-wrap {
  line-height: initial;
}
/* 工具栏 */
#tool-body .toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
#tool-body .toolbar-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#tool-body .toolbar-right { display: flex; align-items: center; gap: 8px; }

#tool-body .btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 0 18px;
  height: 34px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: opacity .2s;
}
#tool-body .btn-primary:hover { opacity: .85; }
#tool-body .btn-primary:disabled { opacity: .45; cursor: not-allowed; }

#tool-body .btn-default {
  background: transparent;
  color: var(--text-color);
  border: 1px solid var(--border-color);
  padding: 0 14px;
  height: 34px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: border-color .2s, color .2s;
}
#tool-body .btn-default:hover { border-color: var(--primary); color: var(--primary); }

#tool-body .btn-danger {
  background: transparent;
  color: #e05454;
  border: 1px solid #e05454;
  padding: 0 14px;
  height: 34px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: all .2s;
}
#tool-body .btn-danger:hover { background: #e05454; color: #fff; }

#tool-body .hint-text {
  font-size: 12px;
  color: var(--text-muted);
}

/* 统计栏 */
#tool-body .stat-bar {
  display: flex;
  gap: 18px;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}
#tool-body .stat-item span { color: var(--primary); font-weight: bold; }

/* JSON 格式化开关 */
#tool-body .toggle-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}

/* 历史地址下拉 */
#tool-body .history-list {
  position: absolute;
  top: 42px; left: 0; right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  z-index: 99;
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
  max-height: 180px;
  overflow-y: auto;
  display: none;
}
#tool-body .history-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background .15s;
}
#tool-body .history-item:hover { background: var(--primary-light); }
#tool-body .history-del { color: var(--text-muted); font-size: 12px; padding: 2px 6px; }
#tool-body .history-del:hover { color: #e05454; }

#tool-body .section-title {
  font-size: 13px;
  font-weight: bold;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
#tool-body .section-title i { color: var(--primary); }

@media (max-width: 640px) {
  #tool-body .conn-row { flex-direction: column; align-items: stretch; }
  #tool-body .toolbar { flex-direction: column; align-items: flex-start; }
}